[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: From Lua to Python?
- From: tobias@...
- Date: Sun, 02 Jul 2017 04:26:54 +0200
Quoting Charles Heywood <vandor2012@gmail.com>:
Yes, I am aware Python’s library is full of warts. But look at something
like subprocess[1] which pretty much nails all the low-level things you
need to use external processes. Notably, it tells you, “to avoid deadlock,
use the communicate() method.”
I see how communicate() is convenient. I would argue that there are helper
libraries out there which allow you to make Lua builtin popen a lot
more useful.
I used my own library lua-t which sports an event loop but I'm sure there is
other stuff out there which provides similar functionality. Note, this is a
very quick'n dirty example without any error checking ...
local Loop = require('t.Loop')
l = Loop(4)
h = io.popen( 'sleep 3 && date' )
l:addHandle( h, 'read', function( handle )
print( handle:read( '*all' ) )
handle:close( )
l:stop()
end, h )
l:run( )
-tobbik