Yelp / python-gearman

Gearman API - Client, worker, and admin client interfaces
http://github.com/Yelp/python-gearman/
Other
242 stars 122 forks source link

sockets should be set close on exec #9

Open rogerbinns opened 13 years ago

rogerbinns commented 13 years ago

The sockets this library makes are not marked close on exec and consequently are inherited by any child processes such as those executed by the subprocess module.

Code is:

    fd = sock.fileno()
    old_flags = fcntl.fcntl(fd, fcntl.F_GETFD)
    fcntl.fcntl(fd, fcntl.F_SETFD, old_flags | fcntl.FD_CLOEXEC)
mtai commented 13 years ago

Added and will be part of the next release

agronick commented 8 years ago

This is still open? I have to shutdown my connections like this to stop them from staying in use:

        for conn in gm_client.connection_list:
            try:
                conn.gearman_socket.shutdown(socket.SHUT_RDWR)
                conn.gearman_socket.close()
                conn._reset_connection()
            except:
                pass