Hi,

The project that I'm working for runs a PostgreSQL database on a remote machine and several Python clients all over the place. The objects usualy have in their constructor a query to the database. As the query is executed on the remote machine, I'm trying to be fancy and execute it while building my Tkinter interface.

The following code illustrates what I'm attempting to do:

<code>
#! /usr/bin/python

from pg import DB
from Tkinter import *

class thrd:
  def __init__(s,r):
    print 'Executing __init__'
    db=DB('design',host='xx.xx.xx.xx',user='yyyy') # relevant IP and user needed
    print 'db=DB(...'
    tkinter.createfilehandler(db,tkinter.READABLE|tkinter.WRITABLE,s.th)
    print 'createfile...'
    Label(r,text='Let\'s see the results').grid()
    print 'Label...'
    s.b=Button(r,text='GO')
    print 's.b=Button...'
    s.b.bind('<Button-1>',s.rslt)
    print 's.b.bind...'
    s.b.grid()
    print 's.b.grid()'
    print '__init__ done'

  def th(s,db,msk):
    print '->Executing th'
    s.r=db.query('select * from customers limit 10').getresult() # some query
    print '->s.r=...'
    tkinter.deletefilehandler(db)
    print '->deletefile...'
    db.close()
    print '->db.close()'
    print '->th done'

  def rslt(s,e):
    for i in s.r:
      print i

if __name__=='__main__':
  r=Tk()
  t=thrd(r)
  r.mainloop()
</code>

The output is:Executing __init__

<code>
db=DB(...
createfile...
Label...
s.b=Button...
s.b.bind...
s.b.grid()
__init__ done
->Executing th
->s.r=...
->deletefile...
->db.close()
->th done
</code>

and it basicly shows that everything happens sequentialy. Pressing the button gives the expected result, so everything is correct. How can I obtain the desired parallelism?

Thanks,
Sorin


Groups are talking. We´re listening. Check out the handy changes to Yahoo! Groups.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to