1
votes

I want to write a program with several interscheduled functions running forever. I thought of using gevent for this purpose. Are their any issues with long running greenlets ?

I am writing a program of this format

from gevent.pool import Pool
from gevent import sleep    

class A(object):
    def a(self):
        while True:
            try:
                * do something *
            except:
                * log exception * 
            sleep(1)

if __name__ == "__main__":
    pool = Pool(5)
    obj = A()
    pool.spawn(obj.a)
    pool.join()
1

1 Answers

1
votes

Other than obj not being defined in this example it should work fine. It doesn't look like you will have any blocking contention problems or GIL issues in this example. These are the only issues I have seen with long running greenlets. That and memory leaks, but that is not a thread specific problem.