Skip to content

Commit

Permalink
Cosmetic: auto reset to 1 thread on macOS and Python 3.8 to prevent t…
Browse files Browse the repository at this point in the history
…he crash #175
  • Loading branch information
alexeigurevich committed Nov 10, 2024
1 parent 0199e6c commit c3eb988
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 18 deletions.
1 change: 1 addition & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
- proper assembly coloring in the MetaQUAST HTML report for more than 14 assemblies;
- catching the Krona charts crashes prematurely;
- proper checking of user BED files in the read alignment mode;
- prevent crashes due to multi-threading on macOS and Python 3.8+ (switch to single-thread);
- cosmetic changes in warning/error messages.

5. Documentation:
Expand Down
18 changes: 0 additions & 18 deletions quast_libs/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,29 +201,11 @@ def error(self, message='', exit_with_code=0, to_stderr=False, indent='', fake_i
self._num_nf_errors += 1

def exception(self, e, exit_code=0):
# FIXME: special case: handling the known bug of macOS & Python3.8+ & joblib
# see: https://github.com/ablab/quast/issues/175
extra_message = ''
if type(e) == TypeError and 'NoneType' in str(e) and 'int' in str(e):
if qconfig.max_threads and qconfig.max_threads > 1 and qconfig.platform_name == 'macosx' and \
sys.version_info.major == 3 and sys.version_info.minor >= 8:
extra_message = '\n\nThis seems to be a known bug when using multi-threading in Python 3.8+ on macOS!\n' \
'The current workarounds are\n' \
' to switch to single-thread execution (-t 1)\n' \
'or\n' \
' to downgrade your Python to 3.7 or below.\n' \
'Sorry for the inconvenience!\n' \
'Please find more details in https://github.com/ablab/quast/issues/175\n'

if self._logger.handlers:
self._logger.error('')
self._logger.exception(e)
if extra_message:
self._logger.info(extra_message)
else:
sys.stderr.write(str(e) + '\n')
if extra_message:
sys.stderr.write(extra_message + '\n')

if exit_code:
exit(exit_code)
Expand Down
8 changes: 8 additions & 0 deletions quast_libs/qconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,14 @@ def set_max_threads(logger):
max_threads = DEFAULT_MAX_THREADS
logger.notice('Maximum number of threads is set to ' + str(max_threads) +
' (use --threads option to set it manually)')
# FIXME: special case: handling the known bug of macOS & Python3.8+ & joblib
# see: https://github.com/ablab/quast/issues/175
if max_threads > 1 and platform_name == 'macosx' and sys.version_info.major == 3 and sys.version_info.minor >= 8:
max_threads = 1
logger.warning('Maximum number of threads is reset to 1 to prevent the crash '
'due to a known bug when using multi-threading in Python 3.8+ on macOS! '
'For multi-threading please downgrade your Python to 3.7. Sorry for the inconvenience! '
'Please find more details in https://github.com/ablab/quast/issues/175')


def quast_version():
Expand Down

0 comments on commit c3eb988

Please sign in to comment.