[OpenStack-Infra] Question about zuul 2.5.2 project zuul.cmd.server.start_gear_server()

Clint Byrum clint at fewbar.com
Wed Aug 16 17:08:02 UTC 2017


That pipe is meant to be used to make the gear server exit when it is
closed. This way if the parent dies, the gear server will get an EPIPE
and die too. It could have also been used as a graceful stop, but it
looks like stop_gear_server just uses SIGKILL to end it quickly.

Excerpts from Huamin Xu's message of 2017-08-16 20:03:32 +0800:
> Dear Senior zuul specialist
> 
>          I am a newcomer about zuul, and wanna to take your zuul into my
> daily work. When i go through zuul source code, i am confused in place
> where zuul.cmd.server.start_gear_server(), and hopeful get your help.
> 
>          'zuul' version is 2.5.2, when zuul server parser the zuul.conf and
> get 'gearman_server'section item 'start', if true, zuul server will start
> gear server.
> 
>      #zuul.cmd.server
>      if (self.config.has_option('gearman_server', 'start') and
> 
>             self.config.getboolean('gearman_server', 'start')):
>             self.start_gear_server()
> 
>         def start_gear_server(self):
> 
>             pipe_read, pipe_write = os.pipe()
>             child_pid = os.fork()
>             if child_pid == 0:
>                 os.close(*pipe_write*)
> 
>                 .....
> 
>             else:
> 
>                os.close(*pipe_read*)
> 
>                .....
> 
> 
>         What confused me is when to close file description created by os.pipe ?
> 
>         According to my understanding, when 'child_pid == 0' is true,
> that is in child process, should close 'pipe_read' not 'pipe_write'.
> 
>         And the same is that when 'child_pid == 0' is false, that is
> in parent process, should close 'pipe_write' not 'pipe_read'.
> 
>         Does my understanding right ?  If not, feel free to tell me
> where am wrong ?  Very thanks.
> 
> 
> Best Wishes
> 
> Xu Huamin  (Hangzhou, China)



More information about the OpenStack-Infra mailing list