<html><body><div style="color:#000; background-color:#fff; font-family:times new roman, new york, times, serif;font-size:12pt"><div><span>Hi Benjamin and folks:</span></div><div><br><span></span></div><div><span>Thanks for the response. I made the change to ll_new_start_thread. Still I get the Ambiguous low-level helper specialization error.</span><br><br></div><div><span>The programme is small. Here is the programme in its entirety. Hopefully it is a silly error. Any help would be appreciated.</span></div><div><br><span></span></div><div><span>Cheers,</span></div><div><span>Andrew<br></span></div><div>-------<br></div><div>import time<br>from pypy.module.thread import ll_thread<br>from pypy.translator.stm import rstm<br><br>NUM_THREADS = 2<br><br>class Account(object):<br> def __init__(self, value):<br> self.value = value<br><br>class Done(object):<br> def
__init__(self):<br> self.done = 0<br><br>fromAccount = Account(1000)<br>toAccount = Account(2000)<br>counter = Done()<br><br><br>def transactionA(source, target, done):<br> print "transaction A starting"<br> source.value -= 50<br> target.value += 50<br> rstm.transaction_boundary()<br> print "Source account %d TargetAccount %d" % (source.value,target.value)<br> print "transaction A done"<br> done.done += 1 <br><br><br>def transactionB(source, target, done):<br> print "transaction B starting"<br> t = source.value * .1<br> source.value -= t<br> target.value += t<br> rstm.transaction_boundary()<br> print "Source account %d Target %d" % (source.value,
target.value)<br> print "transaction A done"<br> done.done += 1<br><br><br>def T1():<br> #global fromAccount, toAccount, counter<br> transactionA(fromAccount, toAccount, counter)<br><br><br>def T2():<br> #global fromAccount, toAccount, counter<br> transactionB(fromAccount, toAccount, counter)<br><br># __________ Entry point __________<br><br>def entry_point(argv):<br> ll_thread.start_new_thread(T1,())<br> ll_thread.start_new_thread(T2,())<br> #ll_thread.ll_start_new_thread(T1)<br> #ll_thread.ll_start_new_thread(T2)<br> print "sleeping..."<br> while counter.done < NUM_THREADS: <br> time.sleep(1)<br> print "done sleeping."<br><br> # easy
way to know if transactions are being serialized correctly<br> assert fromAccount.value + toAccount.value == 3000 <br> return 0<br><br># _____ Define and setup target ___<br><br>def target(*args):<br> return entry_point,
None<br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br><span></span></div><div><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br
><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><b
r><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>def T2():<br> global fromAccount, toAccount, counter<br> transactionB(fromAccount, toAccount, counter)<br><br># __________ Entry point __________<br><br>def entry_point(argv):<br> global fromAccount, toAccount, counter<br> #ll_thread.start_new_thread(T1,())<br> #ll_thread.start_new_thread(T1,())<br> ll_thread.ll_start_new_thread(T1)<br> ll_thread.ll_start_new_thread(T2)<br> print "sleeping..."<br> while counter.done < NUM_THREADS:<br> time.sleep(1)<br> print "done sleeping."<br> assert fromAccount.value + toAccount.value == 3000<br> return 0<br><br># _____ Define and
setup target ___<br><br>def target(*args):<br> return entry_point, None<br><br><br><br><span></span></div><div><br><span></span></div><div><span><br></span></div><div style="font-family: times new roman,new york,times,serif; font-size: 12pt;"> <div style="font-family: times new roman,new york,times,serif; font-size: 12pt;"> <div dir="ltr"> <font face="Arial" size="2"> <hr size="1"> <b><span style="font-weight: bold;">From:</span></b> Benjamin Peterson <benjamin@python.org><br> <b><span style="font-weight: bold;">To:</span></b> Andrew Francis <andrewfr_ice@yahoo.com> <br><b><span style="font-weight: bold;">Cc:</span></b> "pypy-dev@codespeak.net" <pypy-dev@codespeak.net> <br> <b><span style="font-weight: bold;">Sent:</span></b> Monday, January 23, 2012 5:23 PM<br> <b><span style="font-weight: bold;">Subject:</span></b> Re: [pypy-dev] What Causes An Ambiguous low-level helper specialization Error?<br> </font> </div> <br>
2012/1/23 Andrew Francis <<a ymailto="mailto:andrewfr_ice@yahoo.com" href="mailto:andrewfr_ice@yahoo.com">andrewfr_ice@yahoo.com</a>>:<br>> ll_thread.start_new_thread(T1)<br>> ll_thread.start_new_thread(T2)<br><br>Try this:<br> ll_thread.ll_start_new_thread(T1)<br> ll_thread.ll_start_new_thread(T2)<br><br><br><br><br>-- <br>Regards,<br>Benjamin<br><br><br> </div> </div> </div></body></html>