jupyter / jupyter_core

Core Jupyter functionality
https://jupyter-core.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
195 stars 181 forks source link

Add run_sync and ensure_async functions #315

Closed davidbrochart closed 1 year ago

davidbrochart commented 1 year ago

See https://github.com/jupyter/nbclient/pull/259.

davidbrochart commented 1 year ago

To be merged after this PR:

blink1073 commented 1 year ago

Mind adding tests?

blink1073 commented 1 year ago

@meeseeksdev please backport to 4.x

lumberbot-app[bot] commented 1 year ago

Oops, something went wrong applying the patch ... Please have a look at my logs.

blink1073 commented 1 year ago

From the log, it is a merge conflict, but for some reason the bot didn't give the usual message:

2022-11-24T16:33:26.629857+00:00 app[web.1]: hint: To abort and get back to the state before "git cherry-pick",

2022-11-24T16:33:26.629858+00:00 app[web.1]: hint: run "git cherry-pick --abort".'

2022-11-24T16:33:26.629861+00:00 app[web.1]:     [backport] ----

2022-11-24T16:33:26.629863+00:00 app[web.1]:     [backport] 

2022-11-24T16:33:26.629863+00:00 app[web.1]:   stdout: 'Auto-merging jupyter_core/utils/__init__.py

2022-11-24T16:33:26.629865+00:00 app[web.1]: CONFLICT (content): Merge conflict in jupyter_core/utils/__init__.py'

2022-11-24T16:33:26.629920+00:00 app[web.1]:     [backport] ----
davidbrochart commented 1 year ago

I think @fcollonval was having issues with meeseeks lately too.

Carreau commented 1 year ago

Small afer the fact question, why ensure_async(func(param)), which can be problematic if func() can already return an awaitable, and not ensure_asyncfunc(func)(param), that can use inspect.iscoroutinefunction() to make sure func is itself async ?

davidbrochart commented 1 year ago

We just didn't face this situation, but I agree it would have been more generic.