Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Is email package thread safe? (fwd)

Reply
Thread Tools

Is email package thread safe? (fwd)

 
 
Roman Suzi
Guest
Posts: n/a
 
      02-09-2005

(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
 
Reply With Quote
 
 
 
 
Antoon Pardon
Guest
Posts: n/a
 
      02-09-2005
Op 2005-02-09, Roman Suzi schreef <(E-Mail Removed)>:
>
> (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
 
Reply With Quote
 
 
 
 
Diez B. Roggisch
Guest
Posts: n/a
 
      02-09-2005
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
 
Reply With Quote
 
Roman Suzi
Guest
Posts: n/a
 
      02-09-2005
On Wed, 9 Feb 2005, Antoon Pardon wrote:

> Op 2005-02-09, Roman Suzi schreef <(E-Mail Removed)>:
>>
>> 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
--
http://www.velocityreviews.com/forums/(E-Mail Removed) =\= My AI powered by GNU/Linux RedHat 7.3
 
Reply With Quote
 
Antoon Pardon
Guest
Posts: n/a
 
      02-10-2005
Op 2005-02-09, Roman Suzi schreef <(E-Mail Removed)>:
> On Wed, 9 Feb 2005, Antoon Pardon wrote:
>
>> Op 2005-02-09, Roman Suzi schreef <(E-Mail Removed)>:
>>>
>>> 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
 
Reply With Quote
 
Roman Suzi
Guest
Posts: n/a
 
      02-12-2005
On Thu, 10 Feb 2005, Antoon Pardon wrote:

> Op 2005-02-09, Roman Suzi schreef <(E-Mail Removed)>:
>> On Wed, 9 Feb 2005, Antoon Pardon wrote:
>>
>>> Op 2005-02-09, Roman Suzi schreef <(E-Mail Removed)>:
>>>>
>>>> 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
--
(E-Mail Removed) =\= My AI powered by GNU/Linux RedHat 7.3
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Package that imports with name of dependent package David Pratt Python 4 05-13-2006 05:12 PM
single package import v/s the entire package Parvinder Java 6 02-27-2005 02:02 PM
Is email package thread safe? Roman Suzi Python 0 02-07-2005 12:03 PM
package module import name clash with global package George P Python 3 09-11-2004 01:19 PM
Importing a package and looping through modules in the package Dave Python 2 02-10-2004 08:14 PM



Advertisments