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

Question: How to call an async function synchronously #8

Open
dewoller opened this issue Jan 23, 2023 · 0 comments
Open

Question: How to call an async function synchronously #8

dewoller opened this issue Jan 23, 2023 · 0 comments

Comments

@dewoller
Copy link

Hello @ms-jpq , thanks again for the lovely code and tutorial. It is helping me slowly get my head around asynchronous programming. Can you tell me how you would call an one of your async function synchronously?

For example, using your tutorial code:

print('sync example start ')
print( async_tasks_2(1)())
print('sync example end')

prints

sync example start                                                                                                                                                                                                              
sync example end
1 2
3 4

I would like it to print

sync example start                                                                                                                                                                                                              
1 2
3 4
sync example end

:-)

Tutorials in other languages talk about blocking until the task is finished, but if I try to wait without the surrounding sync, there are issues.

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

No branches or pull requests

1 participant