arpakitlib 1.7.95__py3-none-any.whl → 1.7.96__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.
@@ -154,7 +154,7 @@ class BaseOperationExecutor:
154
154
  return operation_dbm
155
155
 
156
156
  def sync_safe_execute_operation(
157
- self, operation_dbm: OperationDBM, worker: OperationExecutorWorker
157
+ self, operation_dbm: OperationDBM, worker: OperationExecutorWorker, session: Session
158
158
  ) -> OperationDBM:
159
159
  self._logger.info(
160
160
  f"start "
@@ -163,20 +163,16 @@ class BaseOperationExecutor:
163
163
  f"operation_dbm.status={operation_dbm.status}"
164
164
  )
165
165
 
166
- with self.sql_alchemy_db.new_session() as session:
167
- operation_dbm: OperationDBM = get_operation_by_id(
168
- session=session, filter_operation_id=operation_dbm.id, raise_if_not_found=True, lock=True
169
- )
170
- operation_dbm.execution_start_dt = now_utc_dt()
171
- operation_dbm.status = OperationDBM.Statuses.executing
172
- operation_dbm.output_data = combine_dicts(
173
- operation_dbm.output_data,
174
- {
175
- worker.worker_fullname: True
176
- }
177
- )
178
- session.commit()
179
- session.refresh(operation_dbm)
166
+ operation_dbm.execution_start_dt = now_utc_dt()
167
+ operation_dbm.status = OperationDBM.Statuses.executing
168
+ operation_dbm.output_data = combine_dicts(
169
+ operation_dbm.output_data,
170
+ {
171
+ worker.worker_fullname: True
172
+ }
173
+ )
174
+ session.commit()
175
+ session.refresh(operation_dbm)
180
176
 
181
177
  exception: BaseException | None = None
182
178
  traceback_str: str | None = None
@@ -191,40 +187,35 @@ class BaseOperationExecutor:
191
187
  exception = exception_
192
188
  traceback_str = traceback.format_exc()
193
189
 
194
- with self.sql_alchemy_db.new_session() as session:
195
-
196
- operation_dbm: OperationDBM = get_operation_by_id(
197
- session=session, filter_operation_id=operation_dbm.id, raise_if_not_found=True, lock=True
190
+ operation_dbm.execution_finish_dt = now_utc_dt()
191
+ if exception:
192
+ operation_dbm.status = OperationDBM.Statuses.executed_with_error
193
+ operation_dbm.error_data = combine_dicts(
194
+ {
195
+ "exception_str": str(exception),
196
+ "traceback_str": traceback_str
197
+ },
198
+ operation_dbm.error_data
198
199
  )
199
- operation_dbm.execution_finish_dt = now_utc_dt()
200
- if exception:
201
- operation_dbm.status = OperationDBM.Statuses.executed_with_error
202
- operation_dbm.error_data = combine_dicts(
203
- {
204
- "exception_str": str(exception),
205
- "traceback_str": traceback_str
206
- },
207
- operation_dbm.error_data
208
- )
209
- else:
210
- operation_dbm.status = OperationDBM.Statuses.executed_without_error
200
+ else:
201
+ operation_dbm.status = OperationDBM.Statuses.executed_without_error
202
+ session.commit()
203
+
204
+ if exception:
205
+ story_log_dbm = StoryLogDBM(
206
+ level=StoryLogDBM.Levels.error,
207
+ title=f"error in sync_execute_operation (id={operation_dbm.id}, type={operation_dbm.type})",
208
+ data={
209
+ "operation_id": operation_dbm.id,
210
+ "exception_str": str(exception),
211
+ "traceback_str": traceback_str
212
+ }
213
+ )
214
+ session.add(story_log_dbm)
211
215
  session.commit()
216
+ session.refresh(story_log_dbm)
212
217
 
213
- if exception:
214
- story_log_dbm = StoryLogDBM(
215
- level=StoryLogDBM.Levels.error,
216
- title=f"error in sync_execute_operation (id={operation_dbm.id}, type={operation_dbm.type})",
217
- data={
218
- "operation_id": operation_dbm.id,
219
- "exception_str": str(exception),
220
- "traceback_str": traceback_str
221
- }
222
- )
223
- session.add(story_log_dbm)
224
- session.commit()
225
- session.refresh(story_log_dbm)
226
-
227
- session.refresh(operation_dbm)
218
+ session.refresh(operation_dbm)
228
219
 
229
220
  self._logger.info(
230
221
  f"finish sync_safe_execute_operation, "
@@ -351,18 +342,21 @@ class OperationExecutorWorker(BaseWorker):
351
342
  self.sqlalchemy_db.init()
352
343
  self.sync_run_startup_funcs()
353
344
 
354
- def sync_execute_operation(self, operation_dbm: OperationDBM) -> OperationDBM:
355
- return self.operation_executor.sync_safe_execute_operation(operation_dbm=operation_dbm, worker=self)
345
+ def sync_execute_operation(self, operation_dbm: OperationDBM, session: Session) -> OperationDBM:
346
+ return self.operation_executor.sync_safe_execute_operation(
347
+ operation_dbm=operation_dbm, worker=self, session=session
348
+ )
356
349
 
357
350
  def sync_run(self):
358
- operation_dbm: OperationDBM | None = get_operation_for_execution(
359
- sqlalchemy_db=self.sqlalchemy_db,
360
- filter_operation_types=self.filter_operation_types,
361
- lock=True
362
- )
363
- if not operation_dbm:
364
- return
365
- self.sync_execute_operation(operation_dbm=operation_dbm)
351
+ with self.sqlalchemy_db.new_session() as session:
352
+ operation_dbm: OperationDBM | None = get_operation_for_execution(
353
+ session=session,
354
+ filter_operation_types=self.filter_operation_types,
355
+ lock=True
356
+ )
357
+ if not operation_dbm:
358
+ return
359
+ self.sync_execute_operation(operation_dbm=operation_dbm, session=session)
366
360
 
367
361
  def sync_run_on_error(self, exception: BaseException, **kwargs):
368
362
  pass
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: arpakitlib
3
- Version: 1.7.95
3
+ Version: 1.7.96
4
4
  Summary: arpakitlib
5
5
  Home-page: https://github.com/ARPAKIT-Company/arpakitlib
6
6
  License: Apache-2.0
@@ -164,7 +164,7 @@ arpakitlib/ar_logging_util.py,sha256=mx3H6CzX9dsh29ruFmYnva8lL6mwvdBXmeHH9E2tvu8
164
164
  arpakitlib/ar_mongodb_util.py,sha256=2ECkTnGAZ92qxioL-fmN6R4yZOSr3bXdXLWTzT1C3vk,4038
165
165
  arpakitlib/ar_need_type_util.py,sha256=GETiREPMEYhch-yU6T--Bdawlbb04Jp1Qy7cOsUlIeA,2228
166
166
  arpakitlib/ar_openai_api_client_util.py,sha256=_XmlApvHFMSyjvZydPa_kASIt9LsFrZmSC7YEzIG8Bg,1806
167
- arpakitlib/ar_operation_execution_util.py,sha256=pSOpYDDT7HE0MgoW3eolJ2bI4eIYI8TUy0jlulmcRHQ,18709
167
+ arpakitlib/ar_operation_execution_util.py,sha256=tm5o-GyinsBQgKCnKJoOizKsqPLmlV1IhADVqARsT6g,18241
168
168
  arpakitlib/ar_parse_command.py,sha256=-s61xcATIsfw1eV_iD3xi-grsitbGzSDoAFc5V0OFy4,3447
169
169
  arpakitlib/ar_postgresql_util.py,sha256=1AuLjEaa1Lg4pzn-ukCVnDi35Eg1k91APRTqZhIJAdo,945
170
170
  arpakitlib/ar_run_cmd_util.py,sha256=D_rPavKMmWkQtwvZFz-Io5Ak8eSODHkcFeLPzNVC68g,1072
@@ -178,9 +178,9 @@ arpakitlib/ar_str_util.py,sha256=tFoGSDYoGpfdVHWor5Li9pEOFmDFlHkX-Z8iOy1LK7Y,353
178
178
  arpakitlib/ar_type_util.py,sha256=s0NsTM7mV3HuwyRwyYLdNn7Ep2HbyI4FIr-dd8x0lfI,3734
179
179
  arpakitlib/ar_yookassa_api_client_util.py,sha256=sh4fcUkAkdOetFn9JYoTvjcSXP-M1wU04KEY-ECLfLg,5137
180
180
  arpakitlib/ar_zabbix_api_client_util.py,sha256=Q-VR4MvoZ9aHwZeYZr9G3LwN-ANx1T5KFmF6pvPM-9M,6402
181
- arpakitlib-1.7.95.dist-info/LICENSE,sha256=GPEDQMam2r7FSTYqM1mm7aKnxLaWcBotH7UvQtea-ec,11355
182
- arpakitlib-1.7.95.dist-info/METADATA,sha256=7AdfJVZL5IKD-fAW1diQvDtisHJlpoQ1EaAxaWbHnEU,2824
183
- arpakitlib-1.7.95.dist-info/NOTICE,sha256=95aUzaPJjVpDsGAsNzVnq7tHTxAl0s5UFznCTkVCau4,763
184
- arpakitlib-1.7.95.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
185
- arpakitlib-1.7.95.dist-info/entry_points.txt,sha256=36xqR3PJFT2kuwjkM_EqoIy0qFUDPKSm_mJaI7emewE,87
186
- arpakitlib-1.7.95.dist-info/RECORD,,
181
+ arpakitlib-1.7.96.dist-info/LICENSE,sha256=GPEDQMam2r7FSTYqM1mm7aKnxLaWcBotH7UvQtea-ec,11355
182
+ arpakitlib-1.7.96.dist-info/METADATA,sha256=NUdQncUnBReSw8GBQxkblcPDWJ5UImdIcZJ15hI5PAg,2824
183
+ arpakitlib-1.7.96.dist-info/NOTICE,sha256=95aUzaPJjVpDsGAsNzVnq7tHTxAl0s5UFznCTkVCau4,763
184
+ arpakitlib-1.7.96.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
185
+ arpakitlib-1.7.96.dist-info/entry_points.txt,sha256=36xqR3PJFT2kuwjkM_EqoIy0qFUDPKSm_mJaI7emewE,87
186
+ arpakitlib-1.7.96.dist-info/RECORD,,