queue-local 0.0.31__tar.gz → 0.0.33__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.
@@ -0,0 +1,18 @@
1
+ Metadata-Version: 2.1
2
+ Name: queue-local
3
+ Version: 0.0.33
4
+ Home-page: https://github.com/circles-zone/queue-local-python-package
5
+ Author: Circles
6
+ Author-email: info@circles.life
7
+ Classifier: Programming Language :: Python :: 3
8
+ Classifier: License :: Other/Proprietary License
9
+ Classifier: Operating System :: OS Independent
10
+ Description-Content-Type: text/markdown
11
+ Requires-Dist: mysql-connector>=2.2.9
12
+ Requires-Dist: pytest>=7.4.1
13
+ Requires-Dist: database-mysql-local>=0.0.120
14
+ Requires-Dist: logger-local>=0.0.59
15
+ Requires-Dist: user-context-remote>=0.0.30
16
+ Requires-Dist: requests>=2.22.0
17
+
18
+ queue-local
@@ -63,7 +63,7 @@ class DatabaseQueue(OurQueue, GenericCRUD):
63
63
  """Pushes a new entry to the queue.
64
64
  data_json consists of columns and values to insert into the queue table."""
65
65
  created_user_id = UserContext().get_effective_user_id()
66
- self.logger.start("Pushing entry to the queue database", object={"data_json": str(data_json)})
66
+ self.logger.start("Pushing entry to the queue database", object={"data_json": data_json})
67
67
 
68
68
  try:
69
69
  self._fix_parameters_json(data_json)
@@ -79,7 +79,7 @@ class DatabaseQueue(OurQueue, GenericCRUD):
79
79
 
80
80
  def push_back(self, queue_item: dict) -> None:
81
81
  """Push a taken queue item back to the queue."""
82
- self.logger.start("Pushing back queue item", object=str(queue_item))
82
+ self.logger.start("Pushing back queue item", object=queue_item)
83
83
  data_json = {"queue_status_id": StatusEnum.NEW.value, "process_id": None}
84
84
  self.update_by_id(id_column_value=queue_item[self.id_column_name], data_json=data_json)
85
85
  self.logger.end("Queue item pushed back successfully")
@@ -97,7 +97,8 @@ class DatabaseQueue(OurQueue, GenericCRUD):
97
97
 
98
98
  try:
99
99
  data_json = {"process_id": os.getpid()}
100
- update_where = f"process_id IS NULL AND queue_status_id = {StatusEnum.NEW.value}" + \
100
+ update_where = f"process_id IS NULL AND queue_status_id = {StatusEnum.NEW.value} AND " \
101
+ f"NOW() > start_timestamp AND (end_timestamp is NULL or NOW() < end_timestamp)" + \
101
102
  (f" AND action_id IN {action_ids}" if action_ids else "")
102
103
  self.update_by_where(where=update_where, order_by="created_timestamp", limit=1, data_json=data_json)
103
104
 
@@ -107,14 +108,14 @@ class DatabaseQueue(OurQueue, GenericCRUD):
107
108
  # Update the selected queue item
108
109
  query = f"UPDATE {self.default_table_name} " \
109
110
  f"SET queue_status_id=%s, updated_user_id=%s, user_jwt=%s, thread_id=%s," \
110
- f"server_ip_v4=%s, server_ip_v6=%s, start_timestamp = NOW() " \
111
+ f"server_ip_v4=%s, server_ip_v6=%s " \
111
112
  f"WHERE {self.id_column_name} = %s"
112
113
  params = (StatusEnum.RETRIEVED.value, updated_user_id, self.user.get_user_JWT(),
113
114
  get_thread_id(), ip_v4, ip_v6, queue_item[self.id_column_name])
114
115
  self.cursor.execute(query, params)
115
116
  self.connection.commit()
116
117
  self.logger.end("Entry retrieved and updated from the queue database successfully",
117
- object={k: str(v) for k, v in queue_item.items()}) # contains a datetime object
118
+ object=queue_item)
118
119
  else:
119
120
  self.logger.end("The queue is empty")
120
121
  except mysql.connector.Error as e:
@@ -144,7 +145,7 @@ class DatabaseQueue(OurQueue, GenericCRUD):
144
145
  elif isinstance(action_ids, Iterable):
145
146
  action_ids = tuple(action_ids)
146
147
  else:
147
- self.logger.error("get_by_action_ids (queue database) invalid argument", object=action_ids)
148
+ self.logger.error("get_by_action_ids (queue database) invalid argument", object={"action_ids": action_ids})
148
149
  raise ValueError("`action_ids` must be a tuple")
149
150
  return action_ids if len(action_ids) != 1 else f"({action_ids[0]})"
150
151
 
@@ -0,0 +1,18 @@
1
+ Metadata-Version: 2.1
2
+ Name: queue-local
3
+ Version: 0.0.33
4
+ Home-page: https://github.com/circles-zone/queue-local-python-package
5
+ Author: Circles
6
+ Author-email: info@circles.life
7
+ Classifier: Programming Language :: Python :: 3
8
+ Classifier: License :: Other/Proprietary License
9
+ Classifier: Operating System :: OS Independent
10
+ Description-Content-Type: text/markdown
11
+ Requires-Dist: mysql-connector>=2.2.9
12
+ Requires-Dist: pytest>=7.4.1
13
+ Requires-Dist: database-mysql-local>=0.0.120
14
+ Requires-Dist: logger-local>=0.0.59
15
+ Requires-Dist: user-context-remote>=0.0.30
16
+ Requires-Dist: requests>=2.22.0
17
+
18
+ queue-local
@@ -3,19 +3,16 @@ import setuptools
3
3
  PACKAGE_NAME = "queue-local"
4
4
  package_dir = PACKAGE_NAME.replace("-", "_")
5
5
 
6
- with open('README.md') as f:
7
- readme = f.read()
8
-
9
6
  setuptools.setup(
10
7
  name=PACKAGE_NAME, # https://pypi.org/project/queue-local
11
- version='0.0.31',
8
+ version='0.0.33',
12
9
  author="Circles",
13
10
  author_email="info@circles.life",
14
11
  url=f"https://github.com/circles-zone/{PACKAGE_NAME}-python-package",
15
12
  packages=[package_dir],
16
13
  package_dir={package_dir: f'{package_dir}/src'},
17
14
  package_data={package_dir: ['*.py']},
18
- long_description=readme,
15
+ long_description="queue-local",
19
16
  long_description_content_type='text/markdown',
20
17
  classifiers=[
21
18
  "Programming Language :: Python :: 3",
@@ -1,75 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: queue-local
3
- Version: 0.0.31
4
- Home-page: https://github.com/circles-zone/queue-local-python-package
5
- Author: Circles
6
- Author-email: info@circles.life
7
- Classifier: Programming Language :: Python :: 3
8
- Classifier: License :: Other/Proprietary License
9
- Classifier: Operating System :: OS Independent
10
- Description-Content-Type: text/markdown
11
- Requires-Dist: mysql-connector>=2.2.9
12
- Requires-Dist: pytest>=7.4.1
13
- Requires-Dist: database-mysql-local>=0.0.120
14
- Requires-Dist: logger-local>=0.0.59
15
- Requires-Dist: user-context-remote>=0.0.30
16
- Requires-Dist: requests>=2.22.0
17
-
18
- # queue-local-python-package
19
-
20
- ## Usage:
21
-
22
- Install:
23
- ```bash
24
- pip install queue-local
25
- ```
26
- - It's recommended to add `queue-local` to your `requirements.txt` file if you're using it as part of your project dependencies.
27
-
28
-
29
- ### Using the `DatabaseQueue` Class:
30
-
31
- ```py
32
- from queue_local.database_queue import DatabaseQueue
33
-
34
- q = DatabaseQueue() # you can also pass some parameters here, see the class definition for more info
35
-
36
- # Push items into the queue
37
- q.push({"item_description": "test 1", "action_id": 1, "parameters_json": "{'a': 1, 'b': 2}"})
38
- q.push({"item_description": "test 2", "action_id": 2, "parameters_json": {'a': 1, 'b': 2}})
39
-
40
- # Peek at the first item in the queue (without removing it)
41
- result1 = q.peek() # "test 1" is still in the queue
42
-
43
- # Get an item from the queue (and remove it) based on action_id
44
- result2 = q.get(action_ids=(2, )) # Gets "test 2" (the first item with action_id=2)
45
-
46
- # Get an item from the queue (and remove it)
47
- result3 = q.get() # Gets "test 1"
48
-
49
- q.close() # close the database connection
50
- ```
51
-
52
-
53
-
54
- ### Inheriting from the Abstract `OurQueue` Class:
55
-
56
- ```py
57
- from queue_local.our_queue import OurQueue
58
-
59
- class YourCustomQueue(OurQueue):
60
- def __init__(self):
61
- pass
62
-
63
- def push(self, item):
64
- """Push an item to the queue"""
65
- pass
66
-
67
- def get(self):
68
- """Get an item from the queue (and delete)"""
69
- pass
70
-
71
- def peek(self):
72
- """Peek at the head of the queue (without deleting)"""
73
- pass
74
- # Add any additional functions you need, such as is_empty()
75
- ```
@@ -1,75 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: queue-local
3
- Version: 0.0.31
4
- Home-page: https://github.com/circles-zone/queue-local-python-package
5
- Author: Circles
6
- Author-email: info@circles.life
7
- Classifier: Programming Language :: Python :: 3
8
- Classifier: License :: Other/Proprietary License
9
- Classifier: Operating System :: OS Independent
10
- Description-Content-Type: text/markdown
11
- Requires-Dist: mysql-connector>=2.2.9
12
- Requires-Dist: pytest>=7.4.1
13
- Requires-Dist: database-mysql-local>=0.0.120
14
- Requires-Dist: logger-local>=0.0.59
15
- Requires-Dist: user-context-remote>=0.0.30
16
- Requires-Dist: requests>=2.22.0
17
-
18
- # queue-local-python-package
19
-
20
- ## Usage:
21
-
22
- Install:
23
- ```bash
24
- pip install queue-local
25
- ```
26
- - It's recommended to add `queue-local` to your `requirements.txt` file if you're using it as part of your project dependencies.
27
-
28
-
29
- ### Using the `DatabaseQueue` Class:
30
-
31
- ```py
32
- from queue_local.database_queue import DatabaseQueue
33
-
34
- q = DatabaseQueue() # you can also pass some parameters here, see the class definition for more info
35
-
36
- # Push items into the queue
37
- q.push({"item_description": "test 1", "action_id": 1, "parameters_json": "{'a': 1, 'b': 2}"})
38
- q.push({"item_description": "test 2", "action_id": 2, "parameters_json": {'a': 1, 'b': 2}})
39
-
40
- # Peek at the first item in the queue (without removing it)
41
- result1 = q.peek() # "test 1" is still in the queue
42
-
43
- # Get an item from the queue (and remove it) based on action_id
44
- result2 = q.get(action_ids=(2, )) # Gets "test 2" (the first item with action_id=2)
45
-
46
- # Get an item from the queue (and remove it)
47
- result3 = q.get() # Gets "test 1"
48
-
49
- q.close() # close the database connection
50
- ```
51
-
52
-
53
-
54
- ### Inheriting from the Abstract `OurQueue` Class:
55
-
56
- ```py
57
- from queue_local.our_queue import OurQueue
58
-
59
- class YourCustomQueue(OurQueue):
60
- def __init__(self):
61
- pass
62
-
63
- def push(self, item):
64
- """Push an item to the queue"""
65
- pass
66
-
67
- def get(self):
68
- """Get an item from the queue (and delete)"""
69
- pass
70
-
71
- def peek(self):
72
- """Peek at the head of the queue (without deleting)"""
73
- pass
74
- # Add any additional functions you need, such as is_empty()
75
- ```
File without changes
File without changes