472,958 Members | 2,592 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,958 software developers and data experts.

Is email package thread safe? (fwd)


(this is a repost with an addition - probably noone noticed my message first
time)

Hi!

Just to be sure, is email package of Python 2.3 thread-safe or not
(to use, for example, in python-milter?)

P.S. And where can I find information on particular piece of standard library
if it is thread-safe or need locking? I recall 'random' module is (was?)
unsafe - which isexplicitly stated in the docs. Can I assume that everything
else without such notice is thread-safe?

Sincerely yours,
Roman A.Souzi

--
http://mail.python.org/mailman/listinfo/python-list
Jul 18 '05 #1
5 1828
Usually, oo-style apis are thread-safe as long as each thread uses its own
objects. Shared global state is _very_ uncommon, and if it's most probably
documented.

--
Regards,

Diez B. Roggisch
Jul 18 '05 #2
Op 2005-02-09, Roman Suzi schreef <rn*@onego.ru>:

(this is a repost with an addition - probably noone noticed my message first
time)

Hi!

Just to be sure, is email package of Python 2.3 thread-safe or not
(to use, for example, in python-milter?)

P.S. And where can I find information on particular piece of standard library
if it is thread-safe or need locking? I recall 'random' module is (was?)
unsafe - which isexplicitly stated in the docs.
Well I guess it was unsafe. The current documentation states:

The underlying implementation in C is both fast and threadsafe.

http://www.python.org/doc/2.3.5/lib/module-random.html

There is class for random number generation that is not thread safe
and is included to allow reproducing sequences from previous versions.
Can I assume that everything
else without such notice is thread-safe?


I doubt it. There is no indication that the email package uses any
kind of locking. So multiple thread working on the same message
will probably screw things up.

--
Antoon Pardon
Jul 18 '05 #3
On Wed, 9 Feb 2005, Antoon Pardon wrote:
Op 2005-02-09, Roman Suzi schreef <rn*@onego.ru>:

Just to be sure, is email package of Python 2.3 thread-safe or not
(to use, for example, in python-milter?) Can I assume that everything
else without such notice is thread-safe?


I doubt it. There is no indication that the email package uses any
kind of locking. So multiple thread working on the same message
will probably screw things up.


Of course, I do not let threads to work on the same message!
I meant that the package doesn't pose other kinds of restrictions.
Can it work in _any_ situation work on two different messages at the same
time, without any interference?
Sincerely yours, Roman Suzi
--
rn*@onego.ru =\= My AI powered by GNU/Linux RedHat 7.3
Jul 18 '05 #4
Op 2005-02-09, Roman Suzi schreef <rn*@onego.ru>:
On Wed, 9 Feb 2005, Antoon Pardon wrote:
Op 2005-02-09, Roman Suzi schreef <rn*@onego.ru>:

Just to be sure, is email package of Python 2.3 thread-safe or not
(to use, for example, in python-milter?) Can I assume that everything
else without such notice is thread-safe?
I doubt it. There is no indication that the email package uses any
kind of locking. So multiple thread working on the same message
will probably screw things up.


Of course, I do not let threads to work on the same message!


Why should that be: "off course"? The random module you spoke about
was also only thread unsafe if you called the same random generator
from various threads. Using a randon generator per thread shouldn't
have been a problem. Since you mentioned that, I thought that was
the kind of thread safety you were after.
I meant that the package doesn't pose other kinds of restrictions.
Can it work in _any_ situation work on two different messages at the same
time, without any interference?


I can't give a guarantee, but there are no global statements and there
doesn't seem to be assignments to cross module variables I think it
would be a safe bet.

--
Antoon Pardon
Jul 18 '05 #5
On Thu, 10 Feb 2005, Antoon Pardon wrote:
Op 2005-02-09, Roman Suzi schreef <rn*@onego.ru>:
On Wed, 9 Feb 2005, Antoon Pardon wrote:
Op 2005-02-09, Roman Suzi schreef <rn*@onego.ru>:

Just to be sure, is email package of Python 2.3 thread-safe or not
(to use, for example, in python-milter?)

Can I assume that everything
else without such notice is thread-safe?

I doubt it. There is no indication that the email package uses any
kind of locking. So multiple thread working on the same message
will probably screw things up.


Of course, I do not let threads to work on the same message!


Why should that be: "off course"? The random module you spoke about
was also only thread unsafe if you called the same random generator
from various threads. Using a randon generator per thread shouldn't
have been a problem. Since you mentioned that, I thought that was
the kind of thread safety you were after.
I meant that the package doesn't pose other kinds of restrictions.
Can it work in _any_ situation work on two different messages at the same
time, without any interference?


I can't give a guarantee, but there are no global statements and there
doesn't seem to be assignments to cross module variables I think it
would be a safe bet.


Thanks to all who discussed this. Really, I had the same thoughts about
1:1 object-thread relation being thread safe. I am doing further research and
if it will give interesting results, I shall post [solved] here.

Sincerely yours, Roman Suzi
--
rn*@onego.ru =\= My AI powered by GNU/Linux RedHat 7.3
Jul 18 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Roman Suzi | last post by:
Hi! Just to be sure, is email package of Python 2.3 thread-safe or not (to use, for example, in python-milter?) Sincerely yours, Roman A.Souzi
117
by: Steevo | last post by:
Any suggestions as to the best programs for cloaking email addresses? Many thanks -- Steevo
2
by: aurora00 | last post by:
Looking at the email package, it seems all the MIMExxx classes takes string but not file object as the payload. I need to handle very large MIME messages say up to 100M. And possibly many of them....
4
by: Jonathan Burd | last post by:
Greetings everyone, Here is a random string generator I wrote for an application and I'm wondering about the thread-safety of this function. I was told using static and global variables cause...
4
by: dwight0 | last post by:
I have a DTS package that can be execute from ASP.net and I was wondering if there is a way to make this thread safe some how. I know thread safe isn't exactly the word I'm looking for but let me...
15
by: Laser Lu | last post by:
I was often noted by Thread Safety declarations when I was reading .NET Framework Class Library documents in MSDN. The declaration is usually described as 'Any public static (Shared in Visual...
1
by: jecheney | last post by:
Hi, Im currently using the following code for reading/writing to a network socket. private StreamReader clientStreamReader; private StreamWriter clientStreamWriter; .... TcpClient tcpClient...
13
by: arun.darra | last post by:
Are the following thread safe: 1. Assuming Object is any simple object Object* fn() { Object *p = new Object(); return p; } 2. is return by value thread safe?
1
by: Laszlo Nagy | last post by:
Hi All, 'm in trouble with decoding email subjects. Here are some examples: I know that "=?UTF-8?B" means UTF-8 + base64 encoding, but I wonder if there is a standard method in the...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.