| Utilities for the OpenFlow test framework |
| default_timeout = None # set by oft |
| default_negative_timeout = None # set by oft |
| return random.randrange(1,0xffffffff) |
| Wait on a condition variable until the given function returns non-None or a timeout expires. |
| The condition variable must already be acquired. |
| The timeout value -1 means use the default timeout. |
| There is deliberately no support for an infinite timeout. |
| def timed_wait(cv, fn, timeout=-1): |
| timeout = default_timeout |
| end_time = time.time() + timeout |
| remaining_time = end_time - time.time() |
| if time.time() > end_time: |
| Similar to a condition variable, but can be passed to select(). |
| Only supports one waiter. |
| self.pipe_rd, self.pipe_wr = os.pipe() |
| fcntl.fcntl(self.pipe_wr, fcntl.F_SETFL, os.O_NONBLOCK) |
| os.write(self.pipe_wr, "x") |
| logging.warn("Failed to notify EventDescriptor: %s", e) |