dsmq 0.3.0__tar.gz → 0.4.0__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.
@@ -1,3 +1,10 @@
1
+ Metadata-Version: 2.3
2
+ Name: dsmq
3
+ Version: 0.4.0
4
+ Summary: A dead simple message queue
5
+ Requires-Python: >=3.10
6
+ Description-Content-Type: text/markdown
7
+
1
8
  # Dead Simple Message Queue
2
9
 
3
10
  ## What it does
@@ -50,6 +57,24 @@ topic = "greetings"
50
57
  msg = mq.get(topic)
51
58
  ```
52
59
 
60
+ ### Spin up and shut down a dsmq in its own process
61
+
62
+ A dsmq server doesn't come with a built-in way to shut itself down.
63
+ It can be helpful to have it running in a separate process that can be
64
+ managed
65
+
66
+ ```python
67
+ import multiprocessing as mp
68
+
69
+ p_mq = mp.Process(target=dsmq.start_server, args=(config.MQ_HOST, config.MQ_PORT))
70
+ p_mq.start()
71
+
72
+ p_mq.join()
73
+ # or
74
+ p_mq.kill()
75
+ p_mq.close()
76
+ ```
77
+
53
78
  ### Demo
54
79
 
55
80
  1. Open 3 separate terminal windows.
@@ -1,11 +1,3 @@
1
- Metadata-Version: 2.3
2
- Name: dsmq
3
- Version: 0.3.0
4
- Summary: A dead simple message queue
5
- License-File: LICENSE
6
- Requires-Python: >=3.10
7
- Description-Content-Type: text/markdown
8
-
9
1
  # Dead Simple Message Queue
10
2
 
11
3
  ## What it does
@@ -58,6 +50,24 @@ topic = "greetings"
58
50
  msg = mq.get(topic)
59
51
  ```
60
52
 
53
+ ### Spin up and shut down a dsmq in its own process
54
+
55
+ A dsmq server doesn't come with a built-in way to shut itself down.
56
+ It can be helpful to have it running in a separate process that can be
57
+ managed
58
+
59
+ ```python
60
+ import multiprocessing as mp
61
+
62
+ p_mq = mp.Process(target=dsmq.start_server, args=(config.MQ_HOST, config.MQ_PORT))
63
+ p_mq.start()
64
+
65
+ p_mq.join()
66
+ # or
67
+ p_mq.kill()
68
+ p_mq.close()
69
+ ```
70
+
61
71
  ### Demo
62
72
 
63
73
  1. Open 3 separate terminal windows.
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "dsmq"
3
- version = "0.3.0"
3
+ version = "0.4.0"
4
4
  description = "A dead simple message queue"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.10"
@@ -65,7 +65,10 @@ class DSMQClientSideConnection:
65
65
  raise RuntimeError("Connection terminated by server")
66
66
  msg_str = data.decode("utf-8")
67
67
  msg = json.loads(msg_str)
68
- return msg
68
+ try:
69
+ return msg["message"]
70
+ except KeyError:
71
+ return ""
69
72
 
70
73
  def put(self, topic, msg):
71
74
  msg = json.dumps({"action": "put", "topic": topic, "message": msg})
@@ -1,4 +1,3 @@
1
- import json
2
1
  import time
3
2
  import dsmq
4
3
 
@@ -1,5 +1,3 @@
1
- import json
2
- import socket
3
1
  import time
4
2
  import dsmq
5
3
 
@@ -3,5 +3,5 @@ requires-python = ">=3.10"
3
3
 
4
4
  [[package]]
5
5
  name = "dsmq"
6
- version = "0.2.0"
6
+ version = "0.4.0"
7
7
  source = { editable = "." }
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes