Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id E7D862E359B for ; Wed, 5 Dec 2007 09:01:06 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 16263-02-5 for ; Wed, 5 Dec 2007 09:01:01 -0400 (AST) Received: from mail.fmed.uba.ar (mail.fmed.uba.ar [157.92.152.1]) by postgresql.org (Postfix) with ESMTP id 28DC42E36D4 for ; Wed, 5 Dec 2007 08:59:33 -0400 (AST) Received: from [157.92.155.58] (mailbis [157.92.155.58]) by mail.fmed.uba.ar (Postfix) with ESMTP id F2C8611ACA5; Wed, 5 Dec 2007 10:01:41 -0300 (ART) Message-ID: <4756A32A.9020101@fmed.uba.ar> Date: Wed, 05 Dec 2007 10:10:02 -0300 From: Gerardo Herzig User-Agent: Mozilla Thunderbird 1.0.7 (X11/20050923) X-Accept-Language: en-us, en MIME-Version: 1.0 To: python-list@python.org, pgsql-sql@postgresql.org Subject: plpythonu and "hello concurrent world" Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200712/12 X-Sequence-Number: 29704 Hi all. Im having some "problems" with a small concurrent plpython function. Based on a small example [1] about concurrent programming, there is some code which works fine under python: #! /usr/bin/python import threading, random import time def myPrint(str): print 'searching...', str time.sleep(random.randint(10, 10000) / 1000.0) print str, 'OK!' myThreads = (threading.Timer(random.random(), myPrint, ["hello"]), \ threading.Timer(random.random(), myPrint, ["concurrent"]), \ threading.Timer(random.random(), myPrint, ["world"])) for thr in myThreads: thr.start() gherzig@linux: python pp.py searching... concurrent searching... world searching... hello hello OK! concurrent OK! world OK! So far, so good. Almost the same example in plpythonu: CREATE OR REPLACE FUNCTION search_t() returns bigint security definer as $$ import threading, random import time def myPrint(str): plpy.notice ('searching...', str) time.sleep(random.randint(10, 10000) / 1000.0) plpy.notice(str, 'OK!') myThreads = (threading.Timer(random.random(), myPrint, ["hello"]), \ threading.Timer(random.random(), myPrint, ["concurrent"]), \ threading.Timer(random.random(), myPrint, ["world"])) for thr in myThreads: thr.start() return 10000 $$ language plpythonu; gse_new_version=# select * From search_t(); search_t ---------- 10000 (1 row) Looks like myPrint() is not executing at all!! Have no idea why, so i decided writing both on python and postgres forums. Any ideas?? Postgres 8.1.3 python 2.5.1 Thanks!! Gerardo [1] http://forums.hostrocket.com/showthread.php?t=13325