Python Module Threading Issue

Alan DeKok aland at deployingradius.com
Sat Aug 18 15:04:27 CEST 2018


On Aug 16, 2018, at 8:07 PM, Gary Gwin <garygwin at gmail.com> wrote:
> I built 3.0.18 from the master branch and reproduced the same concurrency
> issue. The issue manifests under a small load with config of multiple
> modules in multiple sites. I didn't know how to provide the full context
> here:

  I think it's difficult to make Python fully thread-safe:

https://docs.python.org/2/c-api/init.html

...
Note Calling system I/O functions is the most common use case for releasing the GIL, but it can also be useful before calling long-running computations which don’t need access to Python objects, such as compression or cryptographic functions operating over memory buffers. For example, the standard zlib and hashlib modules release the GIL when compressing or hashing data.
...

  That isn't good.

  The short-term fix is to edit the module.  Change the flag at the end from:

	.type		= RLM_TYPE_THREAD_SAFE,

to

	.type		= RLM_TYPE_THREAD_UNSAFE,

  Recompile, re-install, and it will work.

  It will also be slower. But.. slow and correct is better than fast and wrong.

  And for most circumstances (<1K pps) the speed difference shouldn't be noticeable.

  Alan DeKok.




More information about the Freeradius-Users mailing list