473,410 Members | 1,873 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

plpythonu and "hello concurrent world"

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
Dec 5 '07 #1
0 1458

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

Similar topics

2
by: ME | last post by:
I am trying to find a prewritten method for converting a string like this:"Hello World" to this "Hello\sWorld". I plan to use it to build a regular expression. Specifically I am looking for a...
9
by: PG | last post by:
Hi gurus, I have AIX visual age C++ compiler version 5.0.2.3. I have a simple hello world program that gives compilation errors. Any help will be appreciated. Thanks PG ***test.cpp**** ...
6
by: Matthew | last post by:
How would I go about creating a simple "hello world" program that will run in Unix. I am using MS Visual C++.
33
by: ankursinha | last post by:
Hi, Is it possible to write a C program that prints "Hello World" on screen without having a single semi-colon in the entire program? The extra constraint here is that u r not allowed to use...
42
by: Prashanth Badabagni | last post by:
Hi, Can any body tell me how to print "hello,world" with out using semicolon Thanks in advance .. Bye Prashanth Badabagni
8
by: vijay | last post by:
Hello, As the subject suggests, I need to print the string in the reverse order. I made the following program: # include<stdio.h> struct llnode { char *info;
3
by: lovecreatesbeauty | last post by:
Both `K&R C, 2nd' and `C: A reference manual, 5th' introduce the "hello, world" thing using the name "string-constant". But `ISO/IEC 9899:TC2' does not include this kind of thing in section `A.1.5...
4
by: arnuld | last post by:
i am learning C and doing the exercise 1-1 of K&R2, where K&R ask to remove some parts of programme and experiment with error, so here i go: #include <stdio.h> int main () { printf('hello...
0
by: devito | last post by:
hi there, for some days i try to build the boost.python tutorial "hello world" without bjam on winxp by using mingw. so i wrote a *.bat-file like the following: // --- snip...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.