From: Pawel Kedzierski (pawel.kedzierski_at_pwr.edu.pl)
Date: Wed Jul 13 2016 - 03:46:22 CDT

Dear John,
Thank you for the insight. If VMD uses standard console API then it does
look like a bug in Python subprocess module.
Unfortunately I am not competent with windows MS C API but it may be
worth trying if some simple CLI utility like 'sort' will deadlock.
As a workaround I think that creation of a simple tcl script and using
'-e script.tcl' will suffice as with just the stdout pipe there should
be no deadlock.
However at this time I do not even have access to a Windows box with
Python and VMD as my colleague went on holiday, so it must wait.
Thanks,
Pawel

W dniu 13.07.2016 o 08:35, John Stone pisze:
> Hi,
> On Windows, VMD performs it's I/O to stdin/stdout as on Unix, however
> the behavior of stdin/stdout on Windows are determined by the MS C runtime
> and it wouldn't surprise me at all if they don't handle process pipes
> in the way we would expect, furthermore, the Windows console API is used
> by VMD to determine if it has a controlling terminal or if it's doing
> I/O to files. It wouldn't surprise me if some aspect of that is not
> happy when attached through a pipe to the calling Python process.
> I suppose what I would recommend is to compile a simple hello world app
> on Windows and test it the same way you're testing VMD and see if that works
> or if this is a general Python/Windows pipe issue of some kind.
> If you want to communicate with VMD via a Python script, there are also
> other ways, such as having VMD listen to a socket via a short Tcl script
> or similar.
>
> Cheers,
> John Stone
> vmd_at_ks.uiuc.edu
>
> On Mon, Jul 11, 2016 at 10:35:40PM +0200, Pawel Kedzierski wrote:
>> Dear all,
>> I have a Python script which calls 'vmd -startup none -nt -dispdev none
>> -eofexit' with the support of the Popen.communicate() from the
>> subprocess module.
>> I feed a few commands to VMD (load a pdb file and make some
>> atomselect's) to get list of atoms belonging to some selections.
>> This is the recommended way in Python of communication with external
>> programs, and Popen.communicate() run separate threads for writing to
>> the process stdin and to poll stdout in order to avoid deadlocks.
>> Nevertheless, on Windows it does deadlock (tested on Windows 10 x64 with
>> python 2.7, both native and from Cygwin).
>> On Linux the script works.
>> I do not use Windows daily and this was rather for my colleague who is
>> not a Linux native, but still I wonder if this is a Python bug, or maybe
>> VMD does something unusual with stdin/stdout and there is a workaround.
>> Any suggestions or comments are welcome.
>> Cheers,
>> Pawe??
>>
>
>