Checking network input processing by Python for a multi-threaded server

Markus Elfring Markus.Elfring at web.de
Sat May 4 08:56:09 EDT 2019


> If you have a multi-threaded application and you want to be on
> the "safe side", you always use your own locks.

I suggest to reconsider your software expectations around
the word “always”.
There are more software design options available.


> Python uses locks to protect its own data structures.
> Whether this protection is enough for your use of Python types
> depends on details you may not want to worry about.

I agree to such a general view.


> For example: most operations on Python types are atomic
> (if they do not involve some kind of "waiting" or "slow operation")
> *BUT* if they can detroy objects, then arbitrary code
> (from destructors) can be executed and then they are not atomic.

The safe handling of finalizers can trigger development challenges.


> As an example "list.append" is atomic (no object is detroyed),
> but "list[:] = ..." is not: while the list operation itself
> is not interrupted by another thread, the operation may destroy
> objects (the old list components) and other threads may get control
> before the assignment has finished.

How would you determine (with the help of the Python function/class library)
that previously submitted tasks were successfully executed?

Regards,
Markus



More information about the Python-list mailing list