Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

python-proxy can not be stopped automatically #2

Copy link
Copy link
@GoogleCodeExporter

Description

@GoogleCodeExporter
Issue body actions
What steps will reproduce the problem?
1. Run the script from a python script
2.
3.

What is the expected output? What do you see instead?
You are in a infinite loop ! 
If for workaround, you try to launch it into a thread; it's not a good idea 
because in pyhon you can't easily to force the stop it

In my script, I expecte:
- to launch the proxy and continue the script.
- to stop it

What version of the product are you using? On what operating system?
version: '0.1.0 Draft 1'
OS: Windows 7

Please provide any additional information below.

I propose you encapsulate the start/stop in a class:

See below (file in attachment), this example don't take into account the IPV6 
and timeout

class ConnectionHandler(SocketServer.BaseRequestHandler):

    #Instead of __init__
    def handle(self):
        self.client = self.request
    ....

class WebProxy:
    def __init__(self):
        self.server = None


    def start(self, host='localhost', port=8080, IPv6=False, timeout=60,
                      handler=ConnectionHandler):

        print "Start proxy server"
        #For the moment  only in IPV4
        # if IPv6==True:
            # For IPV6, override SocketServer.ThreadingTCPServer
            # soc_type=socket.AF_INET6
        # else:
            # soc_type=socket.AF_INET

        self.server = SocketServer.ThreadingTCPServer((host, port), handler)

        # Start a thread with the server -- that thread will then start one
        # more thread for each request
        server_thread = threading.Thread(target=self.server.serve_forever)
        # Exit the server thread when the main thread terminates
        server_thread.daemon = True
        server_thread.start()

    def stop(self):
        if self.server is not None:
            print "Stop proxy server"
            self.server.shutdown()

Original issue reported on code.google.com by cyrilbes...@aol.com on 28 Mar 2013 at 10:15

Attachments:

Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.