question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ModuleAPI: Provide mechanism for modules to perform async initialisation (that is allowed to fail)

See original GitHub issue

To carry over what was raised here:

Currently a module is instantiated via its __init__ method, which (as a magic method) shouldn’t really be async (as far as I know). What if we have a use-case that involves asynchronous initialisation of a module? E.g. Let’s say we need to translate some non-local room aliases into room IDs on module initialisation and want to report an error (to Synapse) if that fails.

When I say “allowed to fail” (in the title), I mean similarly to how a module’s parse_config static method may fail in a controlled manner.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:10 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
erikjohnstoncommented, Jul 29, 2022

Side thought: perhaps adding a prometheus metric that you can then alert on might give you want you want?

1reaction
erikjohnstoncommented, Jul 29, 2022

No worries! If it turns out there is a use case feel free to reopen 👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

AngularJS : Initialize service with asynchronous data
You can, for example, use the module.constant mechanism to make data available to your app: myApp.constant('myAppConfig', data);.
Read more >
Async Provider Initialization #525 - Urigo/graphql-modules
Is there a way to do initialization of providers that involves asynchronous steps? I want to do something like connect to the database...
Read more >
Initialization, Finalization, and Threads — Python 3.11.1 ...
In an application embedding Python, the Py_Initialize() function must be called before using any other Python/C API functions; with the exception of a...
Read more >
Async hooks | Node.js v19.3.0 Documentation
The node:async_hooks module provides an API to track asynchronous resources. It can be accessed using: import async_hooks from 'node:async_hooks'; ...
Read more >
The Proper Way to Write Async Constructors in JavaScript
The Solution: Static Async Factory Functions!​​ In the first workaround, I hinted at how the constructor may return arbitrary non-primitive ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found