Skip to content

fix(loop): greenlet + async code health code #354

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

Merged
merged 1 commit into from
Dec 9, 2020

Conversation

pavelfeldman
Copy link
Member

  • bubbles the run_until_complete to main.py
  • creates loop if missing
  • removes dispatcher greenlet singleton

@Mattwmaster58
Copy link
Contributor

Mattwmaster58 commented Dec 8, 2020

Something I just encountered is that with Python 3.7 + threads + unix, will fail with this error:

RuntimeError: Cannot add child handler, the child watcher does not have a loop attached

The solution is to make sure there's a asyncio event loop in the main thread and that the child watcher is activated:

# (at file level)
asyncio.get_current_loop()
asyncio.get_child_watcher()

(not necessary in 3.8+ as the default child watcher implementation is better)
Out of the scope this PR, but I feel like a mention in the docs should at least be considered. Or is it too niche a situation/use-case?

@pavelfeldman
Copy link
Member Author

@Mattwmaster58 I'll add some tests for the Thread. Is that just running sync python on a thread use case?

@Mattwmaster58
Copy link
Contributor

Yeah, an example for this setup would gunicorn + flask with endpoints that use the sync interface.

@pavelfeldman pavelfeldman merged commit b9755e2 into microsoft:master Dec 9, 2020
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.

3 participants