gwcelery.util module¶
Miscellaneous utilities that are useful inside many different tasks.
-
gwcelery.util.
handling_system_exit
()¶ Catch any
SystemExit
and re-raise it asRuntimeError
.Some Celery tasks in this package call main functions of command-line tools from other packages. Those main functions may try to exit the Python interpreter (if, for example, the command-line arguments are not understood).
Catch any
SystemExit
exception. If the exit code is zero (signifying a normal exit status), then ignore the exception. If the exit code is nonzero (signifying an error exit status), then re-raise it as aRuntimeError
so that the error is reported but the Celery worker is not killed.
-
gwcelery.util.
NamedTemporaryFile
(content=None, **kwargs)¶ Convenience wrapper for
tempfile.NamedTemporaryFile()
that writes some data to the file before handing it to the calling code.Parameters: - content (str, bytes, None) – Initial contents of the file.
- **kwargs – Additional keyword arguments to pass to
tempfile.NamedTemporaryFile()
.