Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Start server in new thread #180

Open
Mixlu101 opened this issue Jan 13, 2021 · 1 comment
Open

Start server in new thread #180

Mixlu101 opened this issue Jan 13, 2021 · 1 comment

Comments

@Mixlu101
Copy link

Mixlu101 commented Jan 13, 2021

Hi,

I am working on a web project and I would like to use proxybroker server.
I was wondering if it is possible to start the proxybroker server in a new thread so I can next start my web server ?

I tried like this :

# in main thread
thread = threading.Thread(target=run_server)
thread.start()
def run_server():
    host='127.0.0.1'
    port=8888
    types = ['HTTP', 'HTTPS']
    codes = [200, 301, 302]
    
    loop = asyncio.new_event_loop()
    asyncio.set_event_loop(loop)
    broker = Broker(
        max_tries=2,
        loop=loop
    )
    
    broker.serve(
        host=host,
        port=port,
        types=types,
        http_allowed_codes=codes,
        limit=100,
        max_tries=3,
        max_error_rate=0.3,
    )
    
    try:
        loop.run_forever()
    except KeyboardInterrupt:
        broker.stop()
    finally:
        loop.stop()
        loop.close()

But it's not working

Can someone please help ?

@bluet
Copy link

bluet commented Aug 20, 2022

As this project is not maintained by the original developer, we've forked ProxyBroker and continued maintaining the proxybroker2 project since 2020.

If anyone's interested, please join. We need more volunteers. :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants