Python threads

Thomas Wouters thomas at xs4all.net
Sun Nov 5 15:22:56 CET 2000


On Sun, Nov 05, 2000 at 01:13:44AM +0100, ADSL wrote:

> I've started using python on friday, ok, little nice language, with poor
> db support but nice.

'Poor' DB support ? I'm not sure what you are looking for, but Python DB
support is far from poor. There are modules for dbm, gdbm and bsddb (version
1) in the standard library, and many more dbmish modules (bsddb 2, bsddb 3,
dbhash, dbf) and modules for other 'common' formats (like all forms of CSV
files.) As for SQL databases, it might not exceed Perl DBI in all aspects,
but it comes close in many, and suprasses in some ;) There is a common API
for DB modules (DB-API), a generic ODBC module (mxODBC) and there are
'native' modules for at least MySQL, PostgreSQL, Oracle, Sybase, Informix,
Interbase, Solid and Typhoon. See the Vaults of Parnassus for more
information. Just go to http://www.vex.net/parnassus/, and click on
'Databases'.

As for little, I'm sure noone will object to that. The fact that the
language is little is one of its strong points :)

> Now the matter. I've hadn't understand the way python manages threads. I'm
> looking for a decent tutorial the threading module, or at least some piece
> of code on the subject, any hint?

There isn't much to tutor about regarding threads. If you haven't used
threads in any other language, they can be tricky, but programming for
threads in the Python level is dead easy. The library reference sections on
the 'thread' and 'threading' modules tell you how to start threads, how to
do locking, and how to get them to end. All your Python code is 'thread
safe' automatically, but none of the operations are truly atomic (use locks
if you want to ensure data integrity across objects.) You can't corrupt
objects by using threads (they protect themselves,) but you might end up
with inconsistencies.

-- 
Thomas Wouters <thomas at xs4all.net>

Hi! I'm a .signature virus! copy me into your .signature file to help me spread!




More information about the Python-list mailing list