public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] portage r14453 - main/trunk/pym/portage
@ 2009-09-27 21:07 Zac Medico (zmedico)
  0 siblings, 0 replies; only message in thread
From: Zac Medico (zmedico) @ 2009-09-27 21:07 UTC (permalink / raw
  To: gentoo-commits

Author: zmedico
Date: 2009-09-27 21:07:38 +0000 (Sun, 27 Sep 2009)
New Revision: 14453

Modified:
   main/trunk/pym/portage/__init__.py
Log:
Try to avoid blocking on Darwin in _test_pty_eof() by using slave_fd directly
instead of fdopen.


Modified: main/trunk/pym/portage/__init__.py
===================================================================
--- main/trunk/pym/portage/__init__.py	2009-09-27 21:01:49 UTC (rev 14452)
+++ main/trunk/pym/portage/__init__.py	2009-09-27 21:07:38 UTC (rev 14453)
@@ -3754,9 +3754,6 @@
 	# may raise EnvironmentError
 	master_fd, slave_fd = pty.openpty()
 
-	master_file = os.fdopen(master_fd, 'rb')
-	slave_file = os.fdopen(slave_fd, 'wb')
-
 	# Non-blocking mode is required for Darwin kernel.
 	fcntl.fcntl(master_fd, fcntl.F_SETFL,
 		fcntl.fcntl(master_fd, fcntl.F_GETFL) | os.O_NONBLOCK)
@@ -3769,17 +3766,18 @@
 
 	# Simulate a subprocess writing some data to the
 	# slave end of the pipe, and then exiting. Do a
-	# real fork here since otherwise slave_file.close()
+	# real fork here since otherwise os.close(slave_fd)
 	# would block on some platforms such as Darwin.
 	pid = os.fork()
 	if pid == 0:
-		slave_file.write(_unicode_encode(test_string,
+		os.write(slave_fd, _unicode_encode(test_string,
 			encoding='utf_8', errors='strict'))
-		slave_file.close()
+		os.close(slave_fd)
 		os._exit(os.EX_OK)
 	else:
-		slave_file.close()
+		os.close(slave_fd)
 
+	master_file = os.fdopen(master_fd, 'rb')
 	eof = False
 	data = []
 	iwtd = [master_file]




^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2009-09-27 21:07 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-09-27 21:07 [gentoo-commits] portage r14453 - main/trunk/pym/portage Zac Medico (zmedico)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox