EvoluxBR/greenswitch

the "stop method" wait forever if the server does not the response

evangilo opened this issue · 4 comments

the "stop method" wait forever if the server does not the response

Do you have an example? I tried to simulate this with no luck.

I've able to reproduce this issue by calling the "stop" method before "connect" method.

This is an example that will never be used in the production environment but you can reproduce with it. This error could occur when you reject a call too.

#!/usr/bin/env python

import gevent
import greenswitch

class MyApplication(object):
    def __init__(self, session):
        self.session = session

    def run(self):
        try:
            self.safe_run()
        except:
            self.session.stop()

    def safe_run(self):
	print('before stop')
	self.session.stop()
	print('after stop')

server = greenswitch.OutboundESLServer(bind_address='0.0.0.0',
                                       bind_port=5000,
                                       application=MyApplication,
                                       max_connections=5)
server.listen()

The connect() is now part of the accept_call so this scenario is now impossible to happen.