[pypy-dev] What Causes An Ambiguous low-level helper specialization Error?
Andrew Francis
andrewfr_ice at yahoo.com
Tue Jan 24 21:38:48 CET 2012
Hi Benjamin and folks:
Thanks for the response. I made the change to ll_new_start_thread. Still I get the Ambiguous low-level helper specialization error.
The programme is small. Here is the programme in its entirety. Hopefully it is a silly error. Any help would be appreciated.
Cheers,
Andrew
-------
import time
from pypy.module.thread import ll_thread
from pypy.translator.stm import rstm
NUM_THREADS = 2
class Account(object):
def __init__(self, value):
self.value = value
class Done(object):
def __init__(self):
self.done = 0
fromAccount = Account(1000)
toAccount = Account(2000)
counter = Done()
def transactionA(source, target, done):
print "transaction A starting"
source.value -= 50
target.value += 50
rstm.transaction_boundary()
print "Source account %d TargetAccount %d" % (source.value,target.value)
print "transaction A done"
done.done += 1
def transactionB(source, target, done):
print "transaction B starting"
t = source.value * .1
source.value -= t
target.value += t
rstm.transaction_boundary()
print "Source account %d Target %d" % (source.value, target.value)
print "transaction A done"
done.done += 1
def T1():
#global fromAccount, toAccount, counter
transactionA(fromAccount, toAccount, counter)
def T2():
#global fromAccount, toAccount, counter
transactionB(fromAccount, toAccount, counter)
# __________ Entry point __________
def entry_point(argv):
ll_thread.start_new_thread(T1,())
ll_thread.start_new_thread(T2,())
#ll_thread.ll_start_new_thread(T1)
#ll_thread.ll_start_new_thread(T2)
print "sleeping..."
while counter.done < NUM_THREADS:
time.sleep(1)
print "done sleeping."
# easy way to know if transactions are being serialized correctly
assert fromAccount.value + toAccount.value == 3000
return 0
# _____ Define and setup target ___
def target(*args):
return entry_point, None
def T2():
global fromAccount, toAccount, counter
transactionB(fromAccount, toAccount, counter)
# __________ Entry point __________
def entry_point(argv):
global fromAccount, toAccount, counter
#ll_thread.start_new_thread(T1,())
#ll_thread.start_new_thread(T1,())
ll_thread.ll_start_new_thread(T1)
ll_thread.ll_start_new_thread(T2)
print "sleeping..."
while counter.done < NUM_THREADS:
time.sleep(1)
print "done sleeping."
assert fromAccount.value + toAccount.value == 3000
return 0
# _____ Define and setup target ___
def target(*args):
return entry_point, None
________________________________
From: Benjamin Peterson <benjamin at python.org>
To: Andrew Francis <andrewfr_ice at yahoo.com>
Cc: "pypy-dev at codespeak.net" <pypy-dev at codespeak.net>
Sent: Monday, January 23, 2012 5:23 PM
Subject: Re: [pypy-dev] What Causes An Ambiguous low-level helper specialization Error?
2012/1/23 Andrew Francis <andrewfr_ice at yahoo.com>:
> ll_thread.start_new_thread(T1)
> ll_thread.start_new_thread(T2)
Try this:
ll_thread.ll_start_new_thread(T1)
ll_thread.ll_start_new_thread(T2)
--
Regards,
Benjamin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/pypy-dev/attachments/20120124/ae71a00d/attachment.html>
More information about the pypy-dev
mailing list