Allow Synapse modules to specify their own threadpool when calling defer_to_thread#19024
Allow Synapse modules to specify their own threadpool when calling defer_to_thread#19024anoadragon453 wants to merge 2 commits intodevelopfrom
defer_to_thread#19024Conversation
|
|
||
| Added in Synapse v1.49.0. | ||
|
|
||
| Args: |
There was a problem hiding this comment.
Update docstring and details about the default
| async def defer_to_thread( | ||
| self, | ||
| f: Callable[P, T], | ||
| threadpool: Optional[ThreadPool] = None, |
There was a problem hiding this comment.
This will mess with positional args that people are already using with defer_to_thread.
For example: module_api.defer_to_thread(add, 1, 2) will be have 1 interpreted as the threadpool positional argument.
We could use a keyword argument and hope there aren't arg naming collisions with threadpool with the f function. We could further namespace the variable name like defer_to_thread_threadpool
But I think it might be better if we just introduce defer_to_threadpool to the ModuleApi. We need to rely on a new version of the ModuleApi anyway.
There was a problem hiding this comment.
Argh, yes, good point.
While writing this PR, it also felt like a code smell to have the ModuleApi's defer_to_thread actually be defer_to_threadpool under the hood.
I'll rework this PR to expose defer_to_threadpool instead.
|
I've ended up replacing this PR with #19032, which exposes |
Spurred on by matrix-org/synapse-s3-storage-provider#134 (comment). Should be backwards-compatible with all modules.
Superseded by #19032.
Pull Request Checklist
EventStoretoEventWorkerStore.".code blocks.