timeout-decorator icon indicating copy to clipboard operation
timeout-decorator copied to clipboard

Thread stuck in self.__queue.get()

Open odedfos opened this issue 9 years ago • 1 comments

I have a multi-threaded program in which threads call a function decorated with the timeout-decorator:

@timeout_decorator.timeout(seconds=300, use_signals=False)
def some_func(param1, param2):
    ...

Occasionally one of the threads hangs even though the function (some_func) returns successfully.

This happens after a successful function call when trying to dequeue the result in self.__queue.get():

    @property
    def value(self):
        """Read-only property containing data returned from function."""
        if self.ready is True:
            flag, load = self.__queue.get()
            if flag:
                return load
            raise load

It did not reproduce locally, only on prod environment where I used gdb to see what was going on. Going over the timeout code, I could not figure out what would cause this condition.

Perhaps the library is not thread safe? Any other idea what could cause this behavior?

As a safety mechanism perhaps you should set the self.__queue.get() to be non blocking self.__queue.get_nowait()

odedfos avatar Jun 19 '16 11:06 odedfos

I now see that pull request 24 provides this functionality. Will you be merging it anytime soon?

odedfos avatar Jun 19 '16 11:06 odedfos