On Jan 11, 6:17 pm, [EMAIL PROTECTED] wrote: > On Jan 11, 5:51 pm, Paul Rubin <http://[EMAIL PROTECTED]> wrote: > > > > > [EMAIL PROTECTED] writes: > > > listA.op( insert, x ) > > > listA.op( remove, x ) > > > Sure, there are various ways you can make the code look uniform. What > > gets messy is if you want to (say) operate on several lists at the > > same time, which means you need to hold multiple locks simultaneously, > > and some other thread is also trying to do the same thing. If you > > acquire the locks in the wrong order, you can get a situation where > > both threads deadlock forever. > And: > > However, in reality, your rock and hard place are: > > listA.op( listA.insert, x ) > > listA.op( listA.remove, x ) > > > or > > > listA.op( 'insert', x ) > > listA.op( 'remove', x ) > > For a standard library, you may not want to be exposing the potential > for deadlock-- not that users can't do that themselves. > > lockerA.op( listA.extend, [ x ] ) > lockerB.op( listB.reverse ) > def thA(): > gui.listbox.append( lockerA.op( listA.pop ) )
Could you: lockerA= Locker( listA, listB ) lockerA.op( listB.reverse ) lockerA.op( listA.pop ) Where lockerA ops acquire the locks on all its threads? -- http://mail.python.org/mailman/listinfo/python-list