omnata-plugin-runtime 0.5.0a113__tar.gz → 0.5.1a114__tar.gz

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: omnata-plugin-runtime
3
- Version: 0.5.0a113
3
+ Version: 0.5.1a114
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
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "omnata-plugin-runtime"
3
- version = "0.5.0-a113"
3
+ version = "0.5.1-a114"
4
4
  description = "Classes and common runtime components for building and running Omnata Plugins"
5
5
  authors = ["James Weakley <james.weakley@omnata.com>"]
6
6
  readme = "README.md"
@@ -178,10 +178,9 @@ class RateLimitState(SubscriptableBaseModel):
178
178
  [],
179
179
  description="A list of timestamps where previous requests have been made, used to calculate the next request time",
180
180
  )
181
-
182
- _request_timestamps_lock: threading.Lock = PrivateAttr( # or use Any to annotate the type and use Field to initialize
183
- default_factory=lambda: threading.Lock()
184
- )
181
+ # can't set this as a class variable because it's not serializable
182
+ # TODO: probably shouldn't mix models with functionality like this
183
+ _request_timestamps_lock: Optional[threading.Lock] = None
185
184
 
186
185
  @field_serializer('wait_until',when_used='always')
187
186
  def serialize_wait_until(self, value:Optional[datetime.datetime]) -> Optional[int]:
@@ -253,6 +252,8 @@ class RateLimitState(SubscriptableBaseModel):
253
252
  You only need to use this if your HTTP requests are not automatically being
254
253
  registered, which happens if http.client.HTTPConnection is not being used.
255
254
  """
255
+ if self._request_timestamps_lock is None:
256
+ self._request_timestamps_lock = threading.Lock()
256
257
  with self._request_timestamps_lock:
257
258
  append_time = datetime.datetime.now(datetime.timezone.utc)
258
259
  if self.previous_request_timestamps is None: