workercommon 0.4.1__tar.gz → 0.4.2__tar.gz

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.
Files changed (25) hide show
  1. {workercommon-0.4.1 → workercommon-0.4.2}/PKG-INFO +1 -1
  2. {workercommon-0.4.1 → workercommon-0.4.2}/pyproject.toml +1 -1
  3. {workercommon-0.4.1 → workercommon-0.4.2}/workercommon/rabbitmqueue.py +11 -6
  4. {workercommon-0.4.1 → workercommon-0.4.2}/workercommon.egg-info/PKG-INFO +1 -1
  5. {workercommon-0.4.1 → workercommon-0.4.2}/LICENSE.TXT +0 -0
  6. {workercommon-0.4.1 → workercommon-0.4.2}/README.md +0 -0
  7. {workercommon-0.4.1 → workercommon-0.4.2}/setup.cfg +0 -0
  8. {workercommon-0.4.1 → workercommon-0.4.2}/workercommon/__init__.py +0 -0
  9. {workercommon-0.4.1 → workercommon-0.4.2}/workercommon/background.py +0 -0
  10. {workercommon-0.4.1 → workercommon-0.4.2}/workercommon/commands.py +0 -0
  11. {workercommon-0.4.1 → workercommon-0.4.2}/workercommon/config.py +0 -0
  12. {workercommon-0.4.1 → workercommon-0.4.2}/workercommon/connectionpool.py +0 -0
  13. {workercommon-0.4.1 → workercommon-0.4.2}/workercommon/database/__init__.py +0 -0
  14. {workercommon-0.4.1 → workercommon-0.4.2}/workercommon/database/base.py +0 -0
  15. {workercommon-0.4.1 → workercommon-0.4.2}/workercommon/database/pg.py +0 -0
  16. {workercommon-0.4.1 → workercommon-0.4.2}/workercommon/database/py.typed +0 -0
  17. {workercommon-0.4.1 → workercommon-0.4.2}/workercommon/locking.py +0 -0
  18. {workercommon-0.4.1 → workercommon-0.4.2}/workercommon/py.typed +0 -0
  19. {workercommon-0.4.1 → workercommon-0.4.2}/workercommon/test.py +0 -0
  20. {workercommon-0.4.1 → workercommon-0.4.2}/workercommon/worker.py +0 -0
  21. {workercommon-0.4.1 → workercommon-0.4.2}/workercommon.egg-info/SOURCES.txt +0 -0
  22. {workercommon-0.4.1 → workercommon-0.4.2}/workercommon.egg-info/dependency_links.txt +0 -0
  23. {workercommon-0.4.1 → workercommon-0.4.2}/workercommon.egg-info/not-zip-safe +0 -0
  24. {workercommon-0.4.1 → workercommon-0.4.2}/workercommon.egg-info/requires.txt +0 -0
  25. {workercommon-0.4.1 → workercommon-0.4.2}/workercommon.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: workercommon
3
- Version: 0.4.1
3
+ Version: 0.4.2
4
4
  Summary: Support code for various projects
5
5
  Author-email: "Neil E. Hodges" <47hasbegun@gmail.com>
6
6
  License-Expression: BSD-3-Clause
@@ -16,7 +16,7 @@ dependencies = [
16
16
  "psycopg2",
17
17
  "pika",
18
18
  ]
19
- version = "0.4.1"
19
+ version = "0.4.2"
20
20
  license-files = ["LICENSE.TXT"]
21
21
  classifiers = [
22
22
  "Programming Language :: Python :: 3",
@@ -83,7 +83,7 @@ class BaseQueue(object):
83
83
 
84
84
  raise TypeError(f"Cannot serialize: {obj}")
85
85
 
86
- def send_callback(self, message: Any, persist: bool = False) -> None:
86
+ def send_callback(self, message: Any, persist: bool = False, raw: bool = False) -> None:
87
87
  properties = BasicProperties(
88
88
  content_type="application/json",
89
89
  delivery_mode=(
@@ -92,16 +92,21 @@ class BaseQueue(object):
92
92
  )
93
93
 
94
94
  parameters = self.get_parameters()
95
+ serialized = (
96
+ message
97
+ if isinstance(message, str) and raw
98
+ else json.dumps(message, default=self.serialize_for_json)
99
+ )
95
100
  self.get_channel().basic_publish(
96
101
  exchange=parameters.exchange,
97
102
  routing_key=parameters.routing_key,
98
- body=json.dumps(message, default=self.serialize_for_json),
103
+ body=serialized,
99
104
  properties=properties,
100
105
  )
101
106
 
102
- def send(self, message: Any, persist: bool = False) -> None:
107
+ def send(self, message: Any, persist: bool = False, raw: bool = False) -> None:
103
108
  self.add_callback_threadsafe(
104
- partial(self.send_callback, message, persist)
109
+ partial(self.send_callback, message, persist, raw)
105
110
  ).result(60)
106
111
 
107
112
  def add_callback_threadsafe(self, callback: Callable[[], Any]) -> Future:
@@ -256,7 +261,7 @@ class SendQueueWrapper(object):
256
261
  logging.exception(f"Failed to wait for queue thread {self.queue_thread}")
257
262
  self.queue_thread = None
258
263
 
259
- def send(self, message: Any, persist: bool = False) -> None:
264
+ def send(self, message: Any, persist: bool = False, raw: bool = False) -> None:
260
265
  for i in range(self.TRIES):
261
266
  with self.lock:
262
267
  if self.closed:
@@ -268,7 +273,7 @@ class SendQueueWrapper(object):
268
273
  self.queue_thread = self.create_queue_thread(self.queue)
269
274
  logging.info("Re-established broken connection")
270
275
 
271
- self.queue.send(message, persist)
276
+ self.queue.send(message, persist, raw)
272
277
  break
273
278
 
274
279
  except BaseException:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: workercommon
3
- Version: 0.4.1
3
+ Version: 0.4.2
4
4
  Summary: Support code for various projects
5
5
  Author-email: "Neil E. Hodges" <47hasbegun@gmail.com>
6
6
  License-Expression: BSD-3-Clause
File without changes
File without changes
File without changes