Doubt with wx.CallAfter

C

carlosperezs

Hello together::

I have programmed this fuction:

def OnNewMovie(self, event):
""" Local user receives a new movie event from a user"""

#self.log.debug( "Got OnNewMovie, " + `event`)
if event.data[0] == self.pubId:
fDep.write("New movie equal\n")
fDep.flush()
#self.log.debug( "Returning, it's my movie")
# This lets two users connect at the same time
self.lockInitSession.acquire()
if self.vInitSession == False:
self.vInitSession = True
self.lockInitSession.release()
else:
self.lockInitSession.release()

return


#self.log.debug( "Doing remote load event id = " + `event.data[0]` + ",
myid=" + `self.pubId`)
self.lockInitSession.acquire()
self.vInitSession = False
self.lockInitSession.release()

self.sharedAppClient.UpdateDataCache()
self.GetState()
wx.CallAfter(self.sm.RemoteLoadMovie)

This function is a handler that is executed when a event occurs. At the end is
wx.CallAfter call.
Imagine that two events occur simultaneously. This function takes one event.
After executing ax.CallAfter call would tke the second event. Then , my doubt
would be, would be there 2 threads simultanously executing: one belongs to
self.sm.RemoteLoadMovie and the another one belongs to the handler for the
second event?

Thank you. As you can see i do not know exactly how wx.CallAfter works.

--oOo-----------------------------------------------------------------oOo--

Servicio de acceso ó correo electrónico vía web da Universidade de Vigo
Servicio de acceso al correo electrónico vía web de la Universidad de Vigo

Servicios Informáticos [ http://si.uvigo.es ]
Universidade de Vigo [ http://www.uvigo.es ]

URL: https://correoweb.uvigo.es
 
T

Tim Roberts

Hello together::

I have programmed this fuction:

def OnNewMovie(self, event):
""" Local user receives a new movie event from a user"""

#self.log.debug( "Got OnNewMovie, " + `event`)
if event.data[0] == self.pubId:
fDep.write("New movie equal\n")
fDep.flush()
#self.log.debug( "Returning, it's my movie")
# This lets two users connect at the same time
self.lockInitSession.acquire()
if self.vInitSession == False:
self.vInitSession = True
self.lockInitSession.release()
else:
self.lockInitSession.release()
return

#self.log.debug( "Doing remote load event id = " + `event.data[0]` + ",
myid=" + `self.pubId`)
self.lockInitSession.acquire()
self.vInitSession = False
self.lockInitSession.release()

self.sharedAppClient.UpdateDataCache()
self.GetState()
wx.CallAfter(self.sm.RemoteLoadMovie)

This function is a handler that is executed when a event occurs. At the end is
wx.CallAfter call.
Imagine that two events occur simultaneously.

Two events cannot occur simultaneously. It is impossible. There is only
one message queue for your window. All messages will funnel through that
one queue. There is one message loop for the thread that owns the window,
which is pulling messages from the queue and dispatching them to message
handlers. It cannot pull another message from the queue until you have
finished processing this one and returned to the message loop.
This function takes one event.
After executing ax.CallAfter call would tke the second event. Then , my doubt
would be, would be there 2 threads simultanously executing: one belongs to
self.sm.RemoteLoadMovie and the another one belongs to the handler for the
second event?

No. wxCallAfter basically posts another message to the message queue,
which will be handled after all the existing messages have been dispatched.
Windows message handling is quite synchronous.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Doubt with wx.ListCtrl 0
List Ctrl 1
wx.ListCtrl.EditLabel 0
Menu's problem 0
comp.lang.java.gui FAQ 0

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,534
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top