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

Allow Popen.communicate() to read data from the pipe buffer instead of wait() (ESPTOOL-263) #637

Closed
wants to merge 1 commit into from

Conversation

loader-bsd
Copy link
Contributor

@loader-bsd loader-bsd commented Jun 30, 2021

Allow Popen.communicate() to read data from the pipe buffer instead of wait()

- The child process is blocked waiting for the OS pipe buffer to accept more data,
  while test_espefuse_host.py is waiting for the child process to terminate.

  On FreeBSD when a process tries to write(2) more than PIPE_MINDIRECT (8192 bytes) [0]
  at once, it will be blocked at pipe_direct_write() until the receiving process grabs
  all of the bytes from the pipe buffer.

  The test case "burn_efuse -h" [1] writes more than 8192 bytes to the pipe, then child
  process is in the block state (pipdwt) on FreeBSD and process test_espefuse_host.py
  is waiting for it to terminate.

- Popen.communicate() does the reading and calls wait() [2]

[0]: https://cgit.freebsd.org/src/tree/sys/kern/sys_pipe.c?h=releng/13.0#n1132
[1]: https://github.com/espressif/esptool/blob/v3.1/test/test_espefuse_host.py#L320
[2]: https://github.com/python/cpython/blob/v3.8.10/Lib/subprocess.py#L984-L1049

…f wait()

- The child process is blocked waiting for the OS pipe buffer to accept more data,
  while test_espefuse_host.py is waiting for the child process to terminate.

  On FreeBSD when a process tries to write(2) more than PIPE_MINDIRECT (8192 bytes) [0]
  at once, it will be blocked at pipe_direct_write() until the receiving process grabs
  all of the bytes from the pipe buffer.

  The test case "burn_efuse -h" [1] writes more than 8192 bytes to the pipe, then child
  process is in the block state (pipdwt) on FreeBSD and process test_espefuse_host.py
  is waiting for it to terminate.

- Popen.communicate() does the reading and calls wait() [2]

[0]: https://cgit.freebsd.org/src/tree/sys/kern/sys_pipe.c?h=releng/13.0#n1132
[1]: https://github.com/espressif/esptool/blob/v3.1/test/test_espefuse_host.py#L320
[2]: https://github.com/python/cpython/blob/v3.8.10/Lib/subprocess.py#L984-L1049
@github-actions github-actions bot changed the title Allow Popen.communicate() to read data from the pipe buffer instead of wait() Allow Popen.communicate() to read data from the pipe buffer instead of wait() (ESPTOOL-263) Jun 30, 2021
@radimkarnis
Copy link
Collaborator

Hi @loader-bsd,

Thanks for your contribution, LTGM.

I've cherry-picked your commit into our internal review & merge queue, this PR will be updated when it merges.

Radim

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

Successfully merging this pull request may close these issues.

2 participants