pypostal
pypostal copied to clipboard
Release GIL during initialization
This helps mitigate issue #44 this way:
- trigger import of
parse_address
in a dedicated thread. - the PR releases the GIL during the initialization so the other threads are not blocked in python code and can proceed with other tasks.
- if another thread imports
parse_address
, it will wait for the first import to complete.
Example:
import threading
def _import_postal():
from postal.parser import parse_address
threading.Thread(name='import-postal', target=_import_postal, daemon=True).start()
# do something useful until import completes
What's the status on this PR? Does it need more testing or were there issues with it?
FWIW we've been using this in production for some time now.