Changeset 31604 in vbox
- Timestamp:
- Aug 12, 2010 3:17:54 PM (15 years ago)
- svn:sync-xref-src-repo-rev:
- 64728
- Location:
- trunk/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/glue/vboxapi.py
r31601 r31604 271 271 def waitForEvents(self, timeout): 272 272 from win32api import GetCurrentThreadId 273 from win32con import INFINITE 273 274 from win32event import MsgWaitForMultipleObjects, \ 274 275 QS_ALLINPUT, WAIT_TIMEOUT, WAIT_OBJECT_0 275 276 from pythoncom import PumpWaitingMessages 276 277 import types 278 279 if not isinstance(timeout, types.IntType): 280 raise TypeError("The timeout argument is not an integer") 277 281 if (self.tid != GetCurrentThreadId()): 278 282 raise Exception("wait for events from the same thread you inited!") 279 283 280 rc = MsgWaitForMultipleObjects(self.handles, 0, timeout, QS_ALLINPUT) 284 if timeout < 0: cMsTimeout = INFINITE 285 else: cMsTimeout = timeout 286 rc = MsgWaitForMultipleObjects(self.handles, 0, cMsTimeout, QS_ALLINPUT) 281 287 if rc >= WAIT_OBJECT_0 and rc < WAIT_OBJECT_0+len(self.handles): 282 288 # is it possible? … … 559 565 Returns 1 if timed out or interrupted in some way. 560 566 Returns 2 on error (like not supported for web services). 561 Returns None or raises an exception if called on the wrong thread or if 562 the timeout is not an integer value. 567 568 Raises an exception if the calling thread is not the main thread (the one 569 that initialized VirtualBoxManager) or if the time isn't an integer. 563 570 """ 564 571 return self.platform.waitForEvents(timeout) … … 566 573 def interruptWaitEvents(self): 567 574 """ 568 569 575 Interrupt a waitForEvents call. 576 This is normally called from a worker thread. 577 578 Returns True on success, False on failure. 570 579 """ 571 580 return self.platform.interruptWaitEvents() -
trunk/src/libs/xpcom18a4/python/src/module/_xpcom.cpp
r31601 r31604 502 502 PyXPCOMMethod_WaitForEvents(PyObject *self, PyObject *args) 503 503 { 504 PRInt32 aTimeout; 505 506 if (!PyArg_ParseTuple(args, "i", &aTimeout)) 507 return NULL; /** @todo throw exception */ 508 509 int rc; 510 com::EventQueue* aEventQ = com::EventQueue::getMainEventQueue(); 511 NS_WARN_IF_FALSE(aEventQ != nsnull, "Null main event queue"); 512 if (!aEventQ) 513 return NULL; 514 515 Py_BEGIN_ALLOW_THREADS 516 rc = aEventQ->processEventQueue(aTimeout < 0 ? RT_INDEFINITE_WAIT : (uint32_t)aTimeout); 517 Py_END_ALLOW_THREADS 518 if (RT_SUCCESS(rc)) 519 return PyInt_FromLong(0); 520 521 if ( rc == VERR_TIMEOUT 522 || rc == VERR_INTERRUPTED) 523 return PyInt_FromLong(1); 524 525 return PyInt_FromLong(2); 504 PRInt32 aTimeout; 505 506 if (!PyArg_ParseTuple(args, "i", &aTimeout)) 507 { 508 PyErr_SetString(PyExc_TypeError, "the timeout argument is not an integer"); 509 return NULL; 510 } 511 512 int rc; 513 com::EventQueue* aEventQ = com::EventQueue::getMainEventQueue(); 514 NS_WARN_IF_FALSE(aEventQ != nsnull, "Null main event queue"); 515 if (!aEventQ) 516 { 517 PyErr_SetString(PyExc_TypeError, "the main event queue is NULL"); 518 return NULL; 519 } 520 521 Py_BEGIN_ALLOW_THREADS 522 rc = aEventQ->processEventQueue(aTimeout < 0 ? RT_INDEFINITE_WAIT : (uint32_t)aTimeout); 523 Py_END_ALLOW_THREADS 524 if (RT_SUCCESS(rc)) 525 return PyInt_FromLong(0); 526 527 if ( rc == VERR_TIMEOUT 528 || rc == VERR_INTERRUPTED) 529 return PyInt_FromLong(1); 530 531 if (rc == VERR_INVALID_CONTEXT) 532 { 533 PyErr_SetString(PyExc_Exception, "wrong thread, use the main thread"); 534 return NULL; 535 } 536 537 return PyInt_FromLong(2); 526 538 } 527 539
Note:
See TracChangeset
for help on using the changeset viewer.