rlm_python3 behavior with multi-worker threads
Alan DeKok
alan.dekok at inkbridge.io
Wed Sep 24 18:27:50 UTC 2025
On Sep 24, 2025, at 2:18 PM, Erdal Emlik via Freeradius-Users <freeradius-users at lists.freeradius.org> wrote:
> I’m using FreeRADIUS (version 3.2.4) with rlm_python3 for authentication.
Why?
The only time it's required to use Python or Perl is when you need to access an external API, and that API is only available via a Python or Perl library.
> I have the following question:
>
> - Does FreeRADIUS’ thread pool affect rlm_python3 requests?
>
> - Specifically, does each RADIUS worker call the same Python interpreter instance, or does each worker get its own Python context?( i mean 28 workers uses trying to use single instance at the same time right as doc says “item is GLOBAL TO THE SERVER. That is, you cannot have two instances of the python module”)
No, that isn't what the documentation says, You've deleted part of it.
Each thread has it's own Python interpreter.
The document actually says:
# Note that due to limitations on Python, this configuration
# item is GLOBAL TO THE SERVER. That is, you cannot have two
# instances of the python module, each with a different path.
i.e. you CAN have two different instances of the python module. BUT both need to share the same path.
> Additionally, within the Python module, I log requests and sometimes see “queue full” messages.
Because Python is slow, and is blocking the server.
> However, even when these messages appear, I observe that the Python module still returns a response to FreeRADIUS.
No.
Or, the Python module is returning SOME requests to the server. Other requests are blocking for 30+ seconds in the Python module.
Don't run Python.
> Within Python, I perform some comparisons and assign IPs accordingly, and even if a "queue full" exception occurs, FreeRADIUS still receives the IP assignment and returns a response without any issue.
FreeRADIUS supports comparisons in unlang, and IP assignment in unlang. It will be about 1000 times faster than Python.
And no, I'm not exaggerating.
> - Is this “queue full” behavior related to the Python module itself, or is it due to FreeRADIUS threading/queue management?
It's due to the extremely slow script you've created.
a) make the script faster
b) don't use Python.
Pick one.
Alan DeKok.
More information about the Freeradius-Users
mailing list