File tree Expand file tree Collapse file tree 3 files changed +38
-0
lines changed Expand file tree Collapse file tree 3 files changed +38
-0
lines changed Original file line number Diff line number Diff line change 2626
2727from pmtiles_mosaic .tile_sources import create_source_from_paths , MissingTileError
2828
29+ from .utils import relax_open_file_limit
30+
2931def run_external (cmd ):
3032 print (f'running cmd - { cmd } ' )
3133 start = time .time ()
@@ -445,6 +447,8 @@ def retile_main(args):
445447 if tile_extension == 'jpg' :
446448 tile_extension = 'jpeg'
447449
450+ relax_open_file_limit ()
451+
448452 os .environ ['GDAL_CACHEMAX' ] = '2048'
449453 os .environ ['GDAL_MAX_DATASET_POOL_SIZE' ] = '5000'
450454 os .environ ['GDAL_DISABLE_READDIR_ON_OPEN' ] = 'TRUE'
Original file line number Diff line number Diff line change 1313
1414from osgeo_utils .gdal2tiles import submain as gdal2tiles_main
1515
16+ from .utils import relax_open_file_limit
17+
1618SUPPORTED_FORMATS = ['webp' , 'jpeg' , 'png' ]
1719
1820def run_external (cmd ):
@@ -95,6 +97,7 @@ def cli():
9597 else :
9698 attribution_text = args .attribution
9799
100+ relax_open_file_limit ()
98101
99102 tiles_dir = Path (args .tiles_dir )
100103 tiles_dir .mkdir (parents = True , exist_ok = True )
Original file line number Diff line number Diff line change 1+
2+ import resource
3+
4+
5+ def relax_open_file_limit ():
6+
7+ # Get the current soft and hard limits for open files
8+ current_soft , current_hard = resource .getrlimit (resource .RLIMIT_NOFILE )
9+ print (f"Current open file limits: Soft={ current_soft } , Hard={ current_hard } " )
10+
11+ # Set new soft and hard limits for open files
12+ new_soft = resource .RLIM_INFINITY # Set to unlimited
13+ new_hard = resource .RLIM_INFINITY # Set to unlimited
14+
15+ try :
16+ resource .setrlimit (resource .RLIMIT_NOFILE , (new_soft , new_hard ))
17+ print (f"New open file limits set: Soft={ new_soft } , Hard={ new_hard } " )
18+ except Exception as e :
19+ print (f"Error setting resource limit to unlimited: { e } " )
20+ print ('Increasing soft limit to match the hard limit instead' )
21+ new_soft = current_hard
22+ new_hard = current_hard
23+ try :
24+ resource .setrlimit (resource .RLIMIT_NOFILE , (new_soft , new_hard ))
25+ print (f"New open file limits set: Soft={ new_soft } , Hard={ new_hard } " )
26+ except Exception as e :
27+ print (f"Error setting soft resource limit to match hard limit: { e } " )
28+
29+ # Verify the new limits
30+ updated_soft , updated_hard = resource .getrlimit (resource .RLIMIT_NOFILE )
31+ print (f"Verified open file limits: Soft={ updated_soft } , Hard={ updated_hard } " )
You can’t perform that action at this time.
0 commit comments