omnata-plugin-runtime 0.4.6a103__py3-none-any.whl → 0.4.7a104__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.
@@ -706,7 +706,7 @@ class OutboundSyncRequest(SyncRequest):
706
706
  logger.info("applying results to table")
707
707
  # use a random table name with a random string to avoid collisions
708
708
  with self._snowflake_query_lock:
709
- for attempt in Retrying(stop=stop_after_attempt(30),wait=wait_fixed(2),reraise=True,retry=retry_if_exception_message(match=".*is being committed.*")):
709
+ for attempt in Retrying(stop=stop_after_attempt(30),wait=wait_fixed(2),reraise=True,retry=retry_if_exception_message(match=".*(is being|was) committed.*")):
710
710
  with attempt:
711
711
  success, nchunks, nrows, _ = write_pandas(
712
712
  conn=self._session._conn._cursor.connection, # pylint: disable=protected-access
@@ -1345,7 +1345,7 @@ class InboundSyncRequest(SyncRequest):
1345
1345
  """
1346
1346
  if len(results_df) > 0:
1347
1347
  with self._snowflake_query_lock:
1348
- for attempt in Retrying(stop=stop_after_attempt(30),wait=wait_fixed(2),reraise=True,retry=retry_if_exception_message(match=".*is being committed.*")):
1348
+ for attempt in Retrying(stop=stop_after_attempt(30),wait=wait_fixed(2),reraise=True,retry=retry_if_exception_message(match=".*(is being|was) committed.*")):
1349
1349
  with attempt:
1350
1350
  logger.info(
1351
1351
  f"Applying {len(results_df)} results to {self._full_results_table_name}"
@@ -1392,7 +1392,7 @@ class InboundSyncRequest(SyncRequest):
1392
1392
  """
1393
1393
  if len(results_df) > 0:
1394
1394
  with self._snowflake_query_lock:
1395
- for attempt in Retrying(stop=stop_after_attempt(30),wait=wait_fixed(2),reraise=True,retry=retry_if_exception_message(match=".*is being committed.*")):
1395
+ for attempt in Retrying(stop=stop_after_attempt(30),wait=wait_fixed(2),reraise=True,retry=retry_if_exception_message(match=".*(is being|was) committed.*")):
1396
1396
  with attempt:
1397
1397
  logger.info(
1398
1398
  f"Applying {len(results_df)} criteria deletes to {self._criteria_deletes_table_name}"
@@ -2097,50 +2097,61 @@ def managed_inbound_processing(concurrency: int):
2097
2097
 
2098
2098
  tasks:List[threading.Thread] = []
2099
2099
  logger.info(f"Creating {concurrency_to_use} worker(s) for retrieving records")
2100
-
2101
- for i in range(concurrency_to_use):
2102
- # the dataframe/generator was put on the queue, so we remove it from the method args
2103
- task = threading.Thread(
2104
- target=__managed_inbound_processing_worker,
2105
- name=f"managed_inbound_processing_worker_{i}",
2106
- args=(
2107
- self,
2108
- method,
2109
- i,
2110
- streams_queue,
2111
- self._sync_request._thread_cancellation_token,
2112
- method_args,
2113
- method_kwargs,
2114
- ),
2100
+ # if concurrency is set to 1, we don't need to use threads at all
2101
+ if concurrency_to_use == 1:
2102
+ __managed_inbound_processing_worker(
2103
+ self,
2104
+ method,
2105
+ 0,
2106
+ streams_queue,
2107
+ self._sync_request._thread_cancellation_token,
2108
+ method_args,
2109
+ method_kwargs,
2115
2110
  )
2116
- tasks.append(task)
2117
- task.start()
2118
-
2119
- # wait for workers to finish
2120
- while tasks:
2121
- for task in tasks[:]: # shallow copy so we can remove items from the list while iterating
2122
- if not task.is_alive():
2123
- task.join() # Ensure the thread is fully finished
2124
- tasks.remove(task)
2125
- logger.info(f"Thread {task.name} has completed processing")
2126
- time.sleep(1) # Avoid busy waiting
2127
- logger.info("All workers completed processing")
2128
-
2129
- # it's possible that some records weren't applied, since they are processed asynchronously on a timer
2130
- #if self._sync_request.development_mode is False:
2131
- # self._sync_request.apply_results_queue()
2132
- #self._sync_request._thread_cancellation_token.set()
2133
- ## the thread cancellation should be detected by the apply results tasks, so it finishes gracefully
2134
- #if (
2135
- # self._sync_request.development_mode is False
2136
- # and self._sync_request._apply_results_task is not None
2137
- #):
2138
- # self._sync_request._apply_results_task.join()
2139
- if self._sync_request._thread_exception_thrown:
2140
- logger.info("Raising thread exception")
2141
- raise self._sync_request._thread_exception_thrown.exc_value
2142
2111
  else:
2143
- logger.info("No thread exception thrown")
2112
+ for i in range(concurrency_to_use):
2113
+ # the dataframe/generator was put on the queue, so we remove it from the method args
2114
+ task = threading.Thread(
2115
+ target=__managed_inbound_processing_worker,
2116
+ name=f"managed_inbound_processing_worker_{i}",
2117
+ args=(
2118
+ self,
2119
+ method,
2120
+ i,
2121
+ streams_queue,
2122
+ self._sync_request._thread_cancellation_token,
2123
+ method_args,
2124
+ method_kwargs,
2125
+ ),
2126
+ )
2127
+ tasks.append(task)
2128
+ task.start()
2129
+
2130
+ # wait for workers to finish
2131
+ while tasks:
2132
+ for task in tasks[:]: # shallow copy so we can remove items from the list while iterating
2133
+ if not task.is_alive():
2134
+ task.join() # Ensure the thread is fully finished
2135
+ tasks.remove(task)
2136
+ logger.info(f"Thread {task.name} has completed processing")
2137
+ time.sleep(1) # Avoid busy waiting
2138
+ logger.info("All workers completed processing")
2139
+
2140
+ # it's possible that some records weren't applied, since they are processed asynchronously on a timer
2141
+ #if self._sync_request.development_mode is False:
2142
+ # self._sync_request.apply_results_queue()
2143
+ #self._sync_request._thread_cancellation_token.set()
2144
+ ## the thread cancellation should be detected by the apply results tasks, so it finishes gracefully
2145
+ #if (
2146
+ # self._sync_request.development_mode is False
2147
+ # and self._sync_request._apply_results_task is not None
2148
+ #):
2149
+ # self._sync_request._apply_results_task.join()
2150
+ if self._sync_request._thread_exception_thrown:
2151
+ logger.info("Raising thread exception")
2152
+ raise self._sync_request._thread_exception_thrown.exc_value
2153
+ else:
2154
+ logger.info("No thread exception thrown")
2144
2155
  logger.info("Main managed_inbound_processing thread completing")
2145
2156
  return
2146
2157
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: omnata-plugin-runtime
3
- Version: 0.4.6a103
3
+ Version: 0.4.7a104
4
4
  Summary: Classes and common runtime components for building and running Omnata Plugins
5
5
  Author: James Weakley
6
6
  Author-email: james.weakley@omnata.com
@@ -3,10 +3,10 @@ omnata_plugin_runtime/api.py,sha256=W79CsAcl127Dzy-XVS9CzvzsbS3IigVH4QAhFFDkaXg,
3
3
  omnata_plugin_runtime/configuration.py,sha256=7cMekoY8CeZAJHpASU6tCMidF55Hzfr7CD74jtebqIY,35742
4
4
  omnata_plugin_runtime/forms.py,sha256=pw_aKVsXSz47EP8PFBI3VDwdSN5IjvZxp8JTjO1V130,18421
5
5
  omnata_plugin_runtime/logging.py,sha256=bn7eKoNWvtuyTk7RTwBS9UARMtqkiICtgMtzq3KA2V0,3272
6
- omnata_plugin_runtime/omnata_plugin.py,sha256=9ZXKoQTyRV_Yzz_e6wEw7rJtt8YDCNrGT0F0tg7Fecc,108571
6
+ omnata_plugin_runtime/omnata_plugin.py,sha256=b-FCL2D6J0LVrEnZjwvEH37YBX3Hxiy2H1EAKCMNeY0,109206
7
7
  omnata_plugin_runtime/plugin_entrypoints.py,sha256=JAGEdVcy9QEXv7TO5zt7co64LTP8nqGusOc0sJG9GtU,29149
8
8
  omnata_plugin_runtime/rate_limiting.py,sha256=27_sgEkD7kmQlfSF3IaM09Hs8MA5tXuacVUOFR4zwC0,23454
9
- omnata_plugin_runtime-0.4.6a103.dist-info/LICENSE,sha256=IMF9i4xIpgCADf0U-V1cuf9HBmqWQd3qtI3FSuyW4zE,26526
10
- omnata_plugin_runtime-0.4.6a103.dist-info/METADATA,sha256=0nG3b5kY7pgFtBtoVR4fxLIzxlM12MJjiZ6vFD4HyIc,1642
11
- omnata_plugin_runtime-0.4.6a103.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
12
- omnata_plugin_runtime-0.4.6a103.dist-info/RECORD,,
9
+ omnata_plugin_runtime-0.4.7a104.dist-info/LICENSE,sha256=IMF9i4xIpgCADf0U-V1cuf9HBmqWQd3qtI3FSuyW4zE,26526
10
+ omnata_plugin_runtime-0.4.7a104.dist-info/METADATA,sha256=9T3A_FC4NoVQweXGrI9N3TJKl3YgrRAjTreeoUU2240,1642
11
+ omnata_plugin_runtime-0.4.7a104.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
12
+ omnata_plugin_runtime-0.4.7a104.dist-info/RECORD,,