pycares 4.6.1__cp39-cp39-win32.whl → 4.7.0__cp39-cp39-win32.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.
pycares/__init__.py CHANGED
@@ -332,7 +332,8 @@ class Channel:
332
332
  rotate: bool = False,
333
333
  local_ip: Union[str, bytes, None] = None,
334
334
  local_dev: Optional[str] = None,
335
- resolvconf_path: Union[str, bytes, None] = None):
335
+ resolvconf_path: Union[str, bytes, None] = None,
336
+ event_thread: bool = False) -> None:
336
337
 
337
338
  channel = _ffi.new("ares_channel *")
338
339
  options = _ffi.new("struct ares_options *")
@@ -373,6 +374,8 @@ class Channel:
373
374
  if sock_state_cb:
374
375
  if not callable(sock_state_cb):
375
376
  raise TypeError("sock_state_cb is not callable")
377
+ if event_thread:
378
+ raise RuntimeError("sock_state_cb and event_thread cannot be used together")
376
379
 
377
380
  userdata = _ffi.new_handle(sock_state_cb)
378
381
 
@@ -383,6 +386,14 @@ class Channel:
383
386
  options.sock_state_cb_data = userdata
384
387
  optmask = optmask | _lib.ARES_OPT_SOCK_STATE_CB
385
388
 
389
+ if event_thread:
390
+ if not ares_threadsafety():
391
+ raise RuntimeError("c-ares is not built with thread safety")
392
+ if sock_state_cb:
393
+ raise RuntimeError("sock_state_cb and event_thread cannot be used together")
394
+ optmask = optmask | _lib.ARES_OPT_EVENT_THREAD
395
+ options.evsys = _lib.ARES_EVSYS_DEFAULT
396
+
386
397
  if lookups:
387
398
  options.lookups = _ffi.new('char[]', ascii_bytes(lookups))
388
399
  optmask = optmask | _lib.ARES_OPT_LOOKUPS
@@ -422,6 +433,11 @@ class Channel:
422
433
  def cancel(self) -> None:
423
434
  _lib.ares_cancel(self._channel[0])
424
435
 
436
+ def reinit(self) -> None:
437
+ r = _lib.ares_reinit(self._channel[0])
438
+ if r != _lib.ARES_SUCCESS:
439
+ raise AresError(r, errno.strerror(r))
440
+
425
441
  @property
426
442
  def servers(self) -> list[str]:
427
443
  servers = _ffi.new("struct ares_addr_node **")
@@ -847,6 +863,15 @@ class ares_addrinfo_result(AresResult):
847
863
  _lib.ares_freeaddrinfo(ares_addrinfo)
848
864
 
849
865
 
866
+ def ares_threadsafety() -> bool:
867
+ """
868
+ Check if c-ares was compiled with thread safety support.
869
+
870
+ :return: True if thread-safe, False otherwise.
871
+ :rtype: bool
872
+ """
873
+ return bool(_lib.ares_threadsafety())
874
+
850
875
  __all__ = (
851
876
  "ARES_FLAG_USEVC",
852
877
  "ARES_FLAG_PRIMARY",
@@ -903,6 +928,7 @@ __all__ = (
903
928
  "ARES_VERSION",
904
929
  "AresError",
905
930
  "Channel",
931
+ "ares_threadsafety",
906
932
  "errno",
907
933
  "__version__"
908
934
  )
pycares/_cares.pyd CHANGED
Binary file
pycares/_version.py CHANGED
@@ -1,2 +1,2 @@
1
1
 
2
- __version__ = '4.6.1'
2
+ __version__ = '4.7.0'
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pycares
3
- Version: 4.6.1
3
+ Version: 4.7.0
4
4
  Summary: Python interface for c-ares
5
5
  Home-page: http://github.com/saghul/pycares
6
6
  Author: Saúl Ibarra Corretgé
@@ -0,0 +1,12 @@
1
+ pycares/__init__.py,sha256=4pcVxQtqN2b3dYejSn0-5UhVQtnFf-giLhXNhdxO6pg,33615
2
+ pycares/__main__.py,sha256=-WwwGX4NQ8hpOqrNuCy59quCQJt7IAwQXdQjga5s4WA,2880
3
+ pycares/_cares.pyd,sha256=xVQT9slcf8NVvSA7gGEx9qSXmclRu3s_2HFfnntnLN8,183808
4
+ pycares/_version.py,sha256=fQhP4tP6n6MNeE-3CN7K72JQzxJdhExDFIpuwM1P1lI,25
5
+ pycares/errno.py,sha256=32f2SnSjYACq7peW9Iqb7cvDvwup6LDpNMWGHWhLnWI,2340
6
+ pycares/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
+ pycares/utils.py,sha256=ZzjEdkygbU3_B1g4SVwlDS949PhttJG2gK735_6G5Ps,1344
8
+ pycares-4.7.0.dist-info/licenses/LICENSE,sha256=ZzIVbIpf5QFzaiLCDSjxhvH5EViAWLVO-W4ZgBzWvb8,1090
9
+ pycares-4.7.0.dist-info/METADATA,sha256=lxElNQ2gWW8BVtKR3xS9FukhHz6roZi698VnT8KKCHI,4622
10
+ pycares-4.7.0.dist-info/WHEEL,sha256=FOzaaKegzgMCIwD9TvxPZtdwbE7EK7kiZvcKVGaMhYQ,95
11
+ pycares-4.7.0.dist-info/top_level.txt,sha256=nIeo7L2XUVBQZO2YE6pH7tlKaBWTfmmRcXbqe_NWYCw,15
12
+ pycares-4.7.0.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (78.1.1)
2
+ Generator: setuptools (80.1.0)
3
3
  Root-Is-Purelib: false
4
4
  Tag: cp39-cp39-win32
5
5
 
@@ -1,12 +0,0 @@
1
- pycares/__init__.py,sha256=FUE_1XczxLUO4f9jWARbumO4oAWM4eF1UBS9Cs0EiQw,32626
2
- pycares/__main__.py,sha256=-WwwGX4NQ8hpOqrNuCy59quCQJt7IAwQXdQjga5s4WA,2880
3
- pycares/_cares.pyd,sha256=eoLio2RSlSuCes2CfLOmv_Itco3609zK4GkcSLAIjmE,106496
4
- pycares/_version.py,sha256=nMxGyGYNJ1000wnb1Janrs5k6aKCiMEh6a7VTHwXuaI,25
5
- pycares/errno.py,sha256=32f2SnSjYACq7peW9Iqb7cvDvwup6LDpNMWGHWhLnWI,2340
6
- pycares/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
- pycares/utils.py,sha256=ZzjEdkygbU3_B1g4SVwlDS949PhttJG2gK735_6G5Ps,1344
8
- pycares-4.6.1.dist-info/licenses/LICENSE,sha256=ZzIVbIpf5QFzaiLCDSjxhvH5EViAWLVO-W4ZgBzWvb8,1090
9
- pycares-4.6.1.dist-info/METADATA,sha256=RA-2SXrzVC5VSMorEwbeyn1F8QTt2tpHQxwVsh1plp8,4622
10
- pycares-4.6.1.dist-info/WHEEL,sha256=JOlWRbADZkIftSOVi6-MSU0Gc4nk41_GaZ_Q7-6pIWA,95
11
- pycares-4.6.1.dist-info/top_level.txt,sha256=nIeo7L2XUVBQZO2YE6pH7tlKaBWTfmmRcXbqe_NWYCw,15
12
- pycares-4.6.1.dist-info/RECORD,,