question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

The library is not thread-safe

See original GitHub issue
   self_sign_pem_chain = await get_event_loop().run_in_executor(
 File "/usr/lib64/python3.9/concurrent/futures/thread.py", line 52, in run
   result = self.fn(*self.args, **self.kwargs)
 File "/usr/lib/python3.9/site-packages/ideco_crypto/cert.py", line 261, in get_selfgenerated_chain
   common_name = _normalize_domain(common_name, allow_underscore=allow_underscore)
 File "/usr/lib/python3.9/site-packages/ideco_crypto/cert.py", line 76, in _normalize_domain
   return prefix + idna.encode(domain, uts46=True).lower().decode('ascii')
 File "/usr/lib/python3.9/site-packages/idna/core.py", line 349, in encode
   s = uts46_remap(s, std3_rules, transitional)
 File "/usr/lib/python3.9/site-packages/idna/core.py", line 318, in uts46_remap
   from .uts46data import uts46data
ImportError: cannot import name 'uts46data' from partially initialized module 'idna.uts46data' (most likely due to a circular import) (/usr/lib/python3.9/site-packages/idna/uts46data.py)

This happens beacause uts46_remap() imports from .uts46data import uts46data inside. When this happens in two threads in parallel, it leads to error above. Really hard to trigger, but it happens sometimes.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
kjdcommented, Aug 31, 2022

This bug has been open a while and I am keen to fix it. Before I roll up my sleeves and do some research on the best approach, I’d invite anyone who is more familiar with an appropriate idiomatic approach to contribute a patch to resolve it. My aim would be to preserve lazy loading the UTS46 data until needed, if possible.

0reactions
kjdcommented, Sep 13, 2022

I’ve not been able to reproduce this issue, so for now I am going to close this issue. If it can be reproduced happy to reopen.

Read more comments on GitHub >

github_iconTop Results From Across the Web

The library is not thread safe #6256 - pyca/cryptography - GitHub
ObjectIdentifier::_name uses lazy import, which is not thread-safe. ... I think, could be solved by using Threading.lock...or, better, reorganize ...
Read more >
C library functions that are not thread-safe - Arm Developer
The following table shows the C library functions that are not thread-safe. ... These functions are all thread-unsafe. Each contains a static buffer...
Read more >
Thread Safety in Software Libraries on The Example of Anjay
A function or an object is said to be “thread-safe” when it can be called or used from multiple threads without explicit synchronization...
Read more >
12 Developing Thread-safe Libraries
Routines within a library can be thread safe or not. A thread-safe routine is one that can be called concurrently from multiple threads...
Read more >
Does PASOE have any settings for thread-safety?
The AVM has no way of knowing if a given ABL's external shared library (DLL) is thread-safe or not. It is the responsibility...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found