scalable-pypeline 2.1.5__py2.py3-none-any.whl → 2.1.6__py2.py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
pypeline/__init__.py CHANGED
@@ -1 +1 @@
1
- __version__ = "2.1.5"
1
+ __version__ = "2.1.6"
pypeline/constants.py CHANGED
@@ -36,6 +36,7 @@ DEFAULT_BROKER_CONNECTION_ATTEMPTS = int(
36
36
  DEFAULT_BROKER_BLOCKED_CONNECTION_TIMEOUT = int(
37
37
  os.getenv("DEFAULT_BROKER_BLOCKED_CONNECTION_TIMEOUT", 30)
38
38
  )
39
+ DEFAULT_BROKER_HEARTBEAT_TIMEOUT = int("DEFAULT_BROKER_HEARTBEAT_TIMEOUT", 300_000)
39
40
  MESSAGE_BROKER = os.getenv("MESSAGE_BROKER", "RABBITMQ")
40
41
 
41
42
  MS_IN_SECONDS = 1000
pypeline/dramatiq.py CHANGED
@@ -34,6 +34,10 @@ from pypeline.constants import (
34
34
  DEFAULT_BROKER_BLOCKED_CONNECTION_TIMEOUT,
35
35
  DEFAULT_BROKER_CONNECTION_ATTEMPTS,
36
36
  MESSAGE_BROKER,
37
+ DEFAULT_BROKER_HEARTBEAT_TIMEOUT,
38
+ )
39
+ from pypeline.pipelines.middleware.get_active_worker_id_middleware import (
40
+ GetActiveWorkerIdMiddleware,
37
41
  )
38
42
  from pypeline.pipelines.middleware.parallel_pipeline_middleware import ParallelPipeline
39
43
  from pypeline.pipelines.middleware.pypeline_middleware import PypelineMiddleware
@@ -74,12 +78,19 @@ def configure_default_broker(broker: Broker = None):
74
78
  )
75
79
 
76
80
  elif MESSAGE_BROKER == "REDIS":
77
- broker = broker if broker is not None else RedisBroker(url=REDIS_URL)
81
+ broker = (
82
+ broker
83
+ if broker is not None
84
+ else RedisBroker(
85
+ url=REDIS_URL, heartbeat_timeout=DEFAULT_BROKER_HEARTBEAT_TIMEOUT
86
+ )
87
+ )
78
88
 
79
89
  broker.add_middleware(Results(backend=redis_backend))
80
90
  broker.add_middleware(ParallelPipeline(redis_url=REDIS_URL))
81
91
  broker.add_middleware(PypelineMiddleware(redis_url=REDIS_URL))
82
92
  broker.add_middleware(CurrentMessage())
93
+ broker.add_middleware(GetActiveWorkerIdMiddleware())
83
94
  register_actors_for_workers(broker)
84
95
  set_broker(broker)
85
96
 
@@ -0,0 +1,18 @@
1
+ import contextvars
2
+ from dramatiq import Middleware
3
+
4
+
5
+ class GetActiveWorkerIdMiddleware(Middleware):
6
+ _ACTIVE_WORKER_ID: contextvars.ContextVar["Optional[Message[Any]]"] = (
7
+ contextvars.ContextVar("_ACTIVE_WORKER_ID", default=None)
8
+ )
9
+
10
+ @classmethod
11
+ def get_active_worker_id(cls):
12
+ return cls._ACTIVE_WORKER_ID.get()
13
+
14
+ def before_process_message(self, broker, message):
15
+ self._ACTIVE_WORKER_ID.set(broker.broker_id)
16
+
17
+ def after_process_message(self, broker, message, *, result=None, exception=None):
18
+ self._ACTIVE_WORKER_ID.set(None)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: scalable-pypeline
3
- Version: 2.1.5
3
+ Version: 2.1.6
4
4
  Summary: PypeLine - Python pipelines for the Real World
5
5
  Home-page: https://gitlab.com/bravos2/pypeline
6
6
  Author: Bravos Power Corporation
@@ -1,7 +1,7 @@
1
- pypeline/__init__.py,sha256=Ol8KeLnnX1kAXAFgJsZj4d_cZMypHQtaiyICJpuzp64,22
1
+ pypeline/__init__.py,sha256=Z4RaxSmfOjvKssLeOljGX3Csb8I17J-Dc7pSVg3Hb2U,22
2
2
  pypeline/barrier.py,sha256=oO964l9qOCOibweOHyNivmAvufdXOke9nz2tdgclouo,1172
3
- pypeline/constants.py,sha256=415-5fTJQXPO4by14T4BBC6hOn11m96XFiAHSh9Sfxo,2949
4
- pypeline/dramatiq.py,sha256=NyNwAw4iibWnS5GhTVQWxAOfBj3VXkfgSliilMa4ajg,12501
3
+ pypeline/constants.py,sha256=CUo4hHfM0__nMjQq8Sr6N6sW5AwJddvvJhKrcXlST24,3033
4
+ pypeline/dramatiq.py,sha256=5whdOQjzknLjl9lYNj5-f2jRw5ysRPhQExi5NN4KeOY,12837
5
5
  pypeline/extensions.py,sha256=BzOTnXhNxap3N7uIUUh_hO6dDwx08Vc_RJDE93_K0Lo,610
6
6
  pypeline/pipeline_config_schema.py,sha256=hK2_egtg-YFx_XJDs_NyrOTGKkel7W83X-G0sic52sM,10592
7
7
  pypeline/pipeline_settings_schema.py,sha256=84AuNFYsOUpoADsjEo_n9T6Ica-c21oK_V9s15I4lCg,20212
@@ -19,6 +19,7 @@ pypeline/pipelines/composition/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5
19
19
  pypeline/pipelines/composition/parallel_pipeline_composition.py,sha256=pTw9Xb9h4JnV4siFc3JStm5lB-i9djUADo3Kh5K3s7g,12976
20
20
  pypeline/pipelines/composition/pypeline_composition.py,sha256=UBuDKEfRoIbL-9c-HH2ZTVbzfkwFSlNoFH-AVNqt0QE,7965
21
21
  pypeline/pipelines/middleware/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
22
+ pypeline/pipelines/middleware/get_active_worker_id_middleware.py,sha256=g2lDUUoUtD8do-x_XqGurkiKY_eNv0MUYSs5EchRwi0,581
22
23
  pypeline/pipelines/middleware/parallel_pipeline_middleware.py,sha256=kTp6niYoe2nXIiN6EGRfdpxrJyioo0GPxDkfefbGlEk,2821
23
24
  pypeline/pipelines/middleware/pypeline_middleware.py,sha256=IXVqzcOlSJ43lsn-i298RkaeygB-PTJjsvdTDtpgfwg,8141
24
25
  pypeline/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -28,9 +29,9 @@ pypeline/utils/module_utils.py,sha256=-yEJIukDCoXnmlZVXB6Dww25tH6GdPE5SoFqv6pfdV
28
29
  pypeline/utils/pipeline_utils.py,sha256=kGP1QwCJikGC5QNRtzRXCDVewyRMpWIqERTNnxGLlSY,4795
29
30
  pypeline/utils/schema_utils.py,sha256=Fgl0y9Cuo_TZeEx_S3gaSVnLjn6467LTkjb2ek7Ms98,851
30
31
  tests/fixtures/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
31
- scalable_pypeline-2.1.5.dist-info/LICENSE,sha256=DVQuDIgE45qn836wDaWnYhSdxoLXgpRRKH4RuTjpRZQ,10174
32
- scalable_pypeline-2.1.5.dist-info/METADATA,sha256=Fsm58uF_UU13xtUbVLq1bGtxPkwIZRnOvwbpB766URM,5926
33
- scalable_pypeline-2.1.5.dist-info/WHEEL,sha256=bb2Ot9scclHKMOLDEHY6B2sicWOgugjFKaJsT7vwMQo,110
34
- scalable_pypeline-2.1.5.dist-info/entry_points.txt,sha256=uWs10ODfHSBKo2Cx_QaUjPHQTpZ3e77j9VlAdRRmMyg,119
35
- scalable_pypeline-2.1.5.dist-info/top_level.txt,sha256=C7dpkEOc_-nnsAQb28BfQknjD6XHRyS9ZrvVeoIbV7s,15
36
- scalable_pypeline-2.1.5.dist-info/RECORD,,
32
+ scalable_pypeline-2.1.6.dist-info/LICENSE,sha256=DVQuDIgE45qn836wDaWnYhSdxoLXgpRRKH4RuTjpRZQ,10174
33
+ scalable_pypeline-2.1.6.dist-info/METADATA,sha256=BOpe4jN8ylP1iOf8FJyvdgTAF0V66sCEhwaibPvf3_Q,5926
34
+ scalable_pypeline-2.1.6.dist-info/WHEEL,sha256=bb2Ot9scclHKMOLDEHY6B2sicWOgugjFKaJsT7vwMQo,110
35
+ scalable_pypeline-2.1.6.dist-info/entry_points.txt,sha256=uWs10ODfHSBKo2Cx_QaUjPHQTpZ3e77j9VlAdRRmMyg,119
36
+ scalable_pypeline-2.1.6.dist-info/top_level.txt,sha256=C7dpkEOc_-nnsAQb28BfQknjD6XHRyS9ZrvVeoIbV7s,15
37
+ scalable_pypeline-2.1.6.dist-info/RECORD,,