Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release GIL during initialization #74

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ochedru
Copy link

@ochedru ochedru commented Aug 23, 2021

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 ochedru closed this Aug 23, 2021
@ochedru ochedru reopened this Aug 23, 2021
@brandonrobertz
Copy link

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

@ochedru
Copy link
Author

ochedru commented Feb 23, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants