opentf-toolkit-nightly 0.57.0.dev1030__py3-none-any.whl → 0.57.0.dev1044__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.
@@ -43,7 +43,7 @@ from .auth import (
43
43
  get_user_accessible_namespaces,
44
44
  is_user_authorized,
45
45
  )
46
- from .pubsub import make_event, publish, subscribe, unsubscribe
46
+ from .pubsub import make_dispatchqueue, make_event, publish, subscribe, unsubscribe
47
47
  from .schemas import *
48
48
 
49
49
 
@@ -550,7 +550,7 @@ def run_app(app: Flask) -> None:
550
550
  app.logger.info(f'Serving on http://{context["host"]}:{context["port"]}')
551
551
  _app = app
552
552
 
553
- serve(_app, host=context['host'], port=context['port'])
553
+ serve(_app, host=context['host'], port=context['port'], server_name=app.name)
554
554
 
555
555
 
556
556
  ########################################################################
opentf/commons/pubsub.py CHANGED
@@ -17,8 +17,11 @@
17
17
  from typing import Any, Dict, Optional
18
18
 
19
19
  import sys
20
+ import threading
20
21
 
21
22
  from datetime import datetime
23
+ from queue import Queue
24
+ from time import sleep
22
25
 
23
26
 
24
27
  from requests import delete, post, Response
@@ -105,6 +108,51 @@ def _do(req, path: str, eventbus: Dict[str, Any], **kwargs) -> Response:
105
108
  )
106
109
 
107
110
 
111
+ def _dispatch_events(dispatch_queue: Queue, app) -> None:
112
+ """Async event dispatch thread handler."""
113
+ delay = 0
114
+ while True:
115
+ try:
116
+ publication = dispatch_queue.get()
117
+ try:
118
+ publish(publication, app.config['CONTEXT'])
119
+ delay = 0
120
+ except Exception:
121
+ dispatch_queue.put(publication)
122
+ delay = min(2 * delay + 0.2, 60)
123
+ sleep(delay)
124
+ except Exception as err:
125
+ app.logger.error(f'Internal error while dispatching publication: {err}.')
126
+
127
+
128
+ def make_dispatchqueue(app) -> Queue:
129
+ """Make an asynchronous dispatch queue.
130
+
131
+ Handles publication failures by waiting for an increasing delay and
132
+ re-attempting publication.
133
+
134
+ The delay is at most 60 seconds.
135
+
136
+ # Required parameters
137
+
138
+ - app: a flask app
139
+
140
+ # Returned value
141
+
142
+ A _queue_. Events pushed to this queue will be published.
143
+ """
144
+ queue = Queue()
145
+ app.logger.debug('Starting events dispatch thread.')
146
+ try:
147
+ threading.Thread(
148
+ target=_dispatch_events, args=[queue, app], daemon=True
149
+ ).start()
150
+ return queue
151
+ except Exception as err:
152
+ app.logger.error('Cound not start events dispatch thread: %s.', str(err))
153
+ sys.exit(2)
154
+
155
+
108
156
  def subscribe(
109
157
  kind: Optional[str],
110
158
  target: str,
opentf/toolkit/core.py CHANGED
@@ -345,7 +345,7 @@ def touch_file(path: str) -> str:
345
345
  def create_file(path: str, content: str, target: str = 'auto') -> str:
346
346
  """Create file."""
347
347
  marker = make_uuid()
348
- if (runner_on_windows() if target == 'auto' else target) == 'windows':
348
+ if runner_on_windows() if target == 'auto' else (target == 'windows'):
349
349
  encoded = str(base64.b64encode(bytes(content, 'utf8')), 'utf8')
350
350
  what = f'@echo {encoded} > {marker} & @certutil -f -decode {marker} {path} >nul & @del {marker}'
351
351
  else:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: opentf-toolkit-nightly
3
- Version: 0.57.0.dev1030
3
+ Version: 0.57.0.dev1044
4
4
  Summary: OpenTestFactory Orchestrator Toolkit
5
5
  Home-page: https://gitlab.com/henixdevelopment/open-source/opentestfactory/python-toolkit
6
6
  Author: Martin Lafaix
@@ -17,7 +17,7 @@ Requires-Python: >= 3.8.0
17
17
  Description-Content-Type: text/markdown
18
18
  License-File: LICENSE
19
19
  Requires-Dist: requests >=2.31
20
- Requires-Dist: PyJWT[crypto] >=2.7
20
+ Requires-Dist: PyJWT[crypto] <2.9,>=2.7
21
21
  Requires-Dist: PyYAML >=6
22
22
  Requires-Dist: Flask >=2.2.3
23
23
  Requires-Dist: jsonschema >=4.17
@@ -1,9 +1,9 @@
1
- opentf/commons/__init__.py,sha256=KRY8ShQw_0ZZ0oEOiKi4-xnWofE_QsFjEe1T8wUxJ-w,21952
1
+ opentf/commons/__init__.py,sha256=Uq-7WvkMoBiF3C1KnhwIL4LCKpT8EvomnuG4MBYpIhs,21994
2
2
  opentf/commons/auth.py,sha256=bM2Z3kxm2Wku1lKXaRAIg37LHvXWAXIZIqjplDfN2P8,15899
3
3
  opentf/commons/config.py,sha256=dyus4K5Zdmcftc3Y9Z1YRkzA1KwiRLHoeAlg2_A49QM,7876
4
4
  opentf/commons/datasources.py,sha256=4ye-TMtaE88O8GVcWx-FtKXOC8aIZLteR6wfIr7Do8U,25232
5
5
  opentf/commons/expressions.py,sha256=jM_YKXVOFhvOE2aE2IuacuvxhIsOYTFs2oQkpcbWR6g,19645
6
- opentf/commons/pubsub.py,sha256=7khxAHVZiwJRcwIBJ6MPR-f3xY9144-2eNLROwq5F-4,5894
6
+ opentf/commons/pubsub.py,sha256=Y3vOeGNcI4_-uYwBy2grxmn1Oq5r89tyRZZX3mjgiAA,7254
7
7
  opentf/commons/schemas.py,sha256=YSCvlmqc7satt-OqIoYXnmhOyo9h8wIpNyKaBAY4u9c,4039
8
8
  opentf/commons/selectors.py,sha256=DEpLgRAr5HXSpSYI4liXP2hLUTvOSexFa9Vfa1xIQTk,7134
9
9
  opentf/schemas/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -48,9 +48,9 @@ opentf/scripts/launch_java_service.sh,sha256=S0jAaCuv2sZy0Gf2NGBuPX-eD531rcM-b0f
48
48
  opentf/scripts/startup.py,sha256=Da2zo93pBWbdRmj-wgekgLcF94rpNc3ZkbvR8R0w8XY,21279
49
49
  opentf/toolkit/__init__.py,sha256=FLjU1HzD3M4xyLV3uUrec4RdVDyTcpvMGRnZOZtfXfc,22037
50
50
  opentf/toolkit/channels.py,sha256=6xcVKHUK2FdyVKIQmPQbakngfVuQDzCcD_lInOdKpro,17171
51
- opentf/toolkit/core.py,sha256=MvvWUrS4dvo3Qrd_Yl9uND3CllL0qtMi-y1S-Na1uQs,9621
52
- opentf_toolkit_nightly-0.57.0.dev1030.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
53
- opentf_toolkit_nightly-0.57.0.dev1030.dist-info/METADATA,sha256=tl8jxfOQGIz-LRunZYlGjz9NX6kRTEg9hiDvi7803Io,1946
54
- opentf_toolkit_nightly-0.57.0.dev1030.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
55
- opentf_toolkit_nightly-0.57.0.dev1030.dist-info/top_level.txt,sha256=_gPuE6GTT6UNXy1DjtmQSfCcZb_qYA2vWmjg7a30AGk,7
56
- opentf_toolkit_nightly-0.57.0.dev1030.dist-info/RECORD,,
51
+ opentf/toolkit/core.py,sha256=Uc5cRwyi6bs7WVmgvQLTvEa6bXjZ3KfCKWHSdIeUy98,9621
52
+ opentf_toolkit_nightly-0.57.0.dev1044.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
53
+ opentf_toolkit_nightly-0.57.0.dev1044.dist-info/METADATA,sha256=88E1Hd8UjdibvTKeeNB6rW67PGj4k0p6qaG_Tg5SBcs,1951
54
+ opentf_toolkit_nightly-0.57.0.dev1044.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
55
+ opentf_toolkit_nightly-0.57.0.dev1044.dist-info/top_level.txt,sha256=_gPuE6GTT6UNXy1DjtmQSfCcZb_qYA2vWmjg7a30AGk,7
56
+ opentf_toolkit_nightly-0.57.0.dev1044.dist-info/RECORD,,