Skip to content

Commit

Permalink
Merge branch 'fix-attempts'
Browse files Browse the repository at this point in the history
  • Loading branch information
epandurski committed Oct 25, 2023
2 parents 22231a5 + 5ec10e1 commit a4ae595
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
1 change: 1 addition & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
layout python3
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -103,5 +103,8 @@ venv.bak/
# mypy
.mypy_cache/

# direnv subdir
.direnv/

# Emacs backup files
*~
12 changes: 11 additions & 1 deletion flask_melodramatiq/lazy_broker.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,16 @@ def __repr__(self):

def __getattr__(self, name):
if self._proxied_instance is None:
if name in [
'__code__',
'__defaults__',
'__kwdefaults__',
'_is_coroutine_marker',
]:
# For `GenericActor`s, `iscoroutinefunction` may be called
# on unregistered actor proxies, which checks for these
# attribute names.
raise AttributeError
raise RuntimeError(
'init_app() must be called on lazy brokers before use. '
'Did you forget to pass the "app" to broker\'s constructor?'
Expand Down Expand Up @@ -359,7 +369,7 @@ def after_process_boot(self, broker):

class Broker(LazyBrokerMixin, dramatiq.brokers.stub.StubBroker):
__doc__ = LAZY_BROKER_DOCSTRING_TEMPLATE.format(
description="""A lazy broker of dynamically configurable type.
description=r"""A lazy broker of dynamically configurable type.
The type of the broker should be specified by the
"*config_prefix*\_CLASS" setting in the Flask application
Expand Down
2 changes: 1 addition & 1 deletion tests/test_basics.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,6 @@ def task():
worker.start()
worker.join()

match = "default broker doesn't have a results backend"
match = "broker doesn't have a results backend"
with pytest.raises(RuntimeError, match=match):
job.get_result()

0 comments on commit a4ae595

Please sign in to comment.