pypostal icon indicating copy to clipboard operation
pypostal copied to clipboard

Release GIL during initialization

Open ochedru opened this issue 2 years ago • 2 comments

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

ochedru avatar Aug 23 '21 14:08 ochedru

What's the status on this PR? Does it need more testing or were there issues with it?

brandonrobertz avatar Feb 22 '24 17:02 brandonrobertz

FWIW we've been using this in production for some time now.

ochedru avatar Feb 23 '24 14:02 ochedru