Re: Strangeness: Cannot write to a file from a process created by Windows Task Scheduler ...

2009-10-26 Thread MRAB

Sandy Walsh wrote:
Yes it seems to be a flush problem. Strange how it doesn't require the 
explicit flush() when the console window appears, but does otherwise. 
Either way, it gives me a good direction to chase after.



[snip]
It buffers for efficiency reasons, but if it can detect that it's
connected to a console then it won't bother buffering because there's
nothing to gain.

--
http://mail.python.org/mailman/listinfo/python-list


Re: Strangeness: Cannot write to a file from a process created by Windows Task Scheduler ...

2009-10-26 Thread Sandy Walsh

Thanks Marco & Al,

Yes it seems to be a flush problem. Strange how it doesn't require the 
explicit flush() when the console window appears, but does otherwise. 
Either way, it gives me a good direction to chase after.


Thanks again for your quick help guys!
-Sandy


Marco Bizzarri wrote:

You could try to flush the file? Maybe it would flush once you close,
which never happens; did you try to limit the amount of times it run
inside the 'while' loop?

Regards
Marco



On Mon, Oct 26, 2009 at 6:17 PM, Sandy Walsh  wrote:
  

Hi there,

Seeing some really weird behavior and perhaps someone has seen something
similar:

I have a python script that launches as a Windows Scheduled Task. The
program simply opens a disk file and writes some text to it:

---
f = open("waiting.txt", "w")
x = 0
while 1:
  f.write("Sleeping: %d\r\n" % x)
  x += 1
  time.sleep(2)

f.close()
---

I've run it under my user account. I've run it as Local Account. I've run it
via pythonw and python ... only one way works:

When I run with full credentials (not local account) and python (not
pythonw) I get output in the file (and a CMD window appears while it's
running). In every other combination it creates the 'waiting.txt' file, but
doesn't write any output to the file. The length of the file is 0 bytes.

Anyone have ideas what could be causing this? I suspect it's blocking on
something, but I can't imagine where.

There is no stderr/stdout output anywhere in the program so it's not
blocking on anything stdio related (that I can imagine)

Thoughts?
-Sandy



--
http://mail.python.org/mailman/listinfo/python-list







  


<>-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Strangeness: Cannot write to a file from a process created by Windows Task Scheduler ...

2009-10-26 Thread MRAB

Sandy Walsh wrote:

Hi there,

Seeing some really weird behavior and perhaps someone has seen something 
similar:


I have a python script that launches as a Windows Scheduled Task. The 
program simply opens a disk file and writes some text to it:


---
f = open("waiting.txt", "w")
x = 0
while 1:
   f.write("Sleeping: %d\r\n" % x)
   x += 1
   time.sleep(2)

f.close()
---

I've run it under my user account. I've run it as Local Account. I've 
run it via pythonw and python ... only one way works:


When I run with full credentials (not local account) and python (not 
pythonw) I get output in the file (and a CMD window appears while it's 
running). In every other combination it creates the 'waiting.txt' file, 
but doesn't write any output to the file. The length of the file is 0 
bytes.


Anyone have ideas what could be causing this? I suspect it's blocking on 
something, but I can't imagine where.


There is no stderr/stdout output anywhere in the program so it's not 
blocking on anything stdio related (that I can imagine)


Thoughts?


1. I don't see "import time" anywhere.

2. Output to the file is buffered. When the script is terminated
whatever is still in the output buffer will be lost.

BTW, the "f.close()" is pointless because of the infinite loop.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Strangeness: Cannot write to a file from a process created by Windows Task Scheduler ...

2009-10-26 Thread Marco Bizzarri
You could try to flush the file? Maybe it would flush once you close,
which never happens; did you try to limit the amount of times it run
inside the 'while' loop?

Regards
Marco



On Mon, Oct 26, 2009 at 6:17 PM, Sandy Walsh  wrote:
> Hi there,
>
> Seeing some really weird behavior and perhaps someone has seen something
> similar:
>
> I have a python script that launches as a Windows Scheduled Task. The
> program simply opens a disk file and writes some text to it:
>
> ---
> f = open("waiting.txt", "w")
> x = 0
> while 1:
>   f.write("Sleeping: %d\r\n" % x)
>   x += 1
>   time.sleep(2)
>
> f.close()
> ---
>
> I've run it under my user account. I've run it as Local Account. I've run it
> via pythonw and python ... only one way works:
>
> When I run with full credentials (not local account) and python (not
> pythonw) I get output in the file (and a CMD window appears while it's
> running). In every other combination it creates the 'waiting.txt' file, but
> doesn't write any output to the file. The length of the file is 0 bytes.
>
> Anyone have ideas what could be causing this? I suspect it's blocking on
> something, but I can't imagine where.
>
> There is no stderr/stdout output anywhere in the program so it's not
> blocking on anything stdio related (that I can imagine)
>
> Thoughts?
> -Sandy
>
>
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
>



-- 
Marco Bizzarri
http://code.google.com/p/qt-asterisk/
http://notenotturne.blogspot.com/
http://iliveinpisa.blogspot.com/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Strangeness: Cannot write to a file from a process created by Windows Task Scheduler ...

2009-10-26 Thread Al Fansome

Do you "import time"?

Sandy Walsh wrote:

Hi there,

Seeing some really weird behavior and perhaps someone has seen something 
similar:


I have a python script that launches as a Windows Scheduled Task. The 
program simply opens a disk file and writes some text to it:


---
f = open("waiting.txt", "w")
x = 0
while 1:
   f.write("Sleeping: %d\r\n" % x)
   x += 1
   time.sleep(2)

f.close()
---

I've run it under my user account. I've run it as Local Account. I've 
run it via pythonw and python ... only one way works:


When I run with full credentials (not local account) and python (not 
pythonw) I get output in the file (and a CMD window appears while it's 
running). In every other combination it creates the 'waiting.txt' file, 
but doesn't write any output to the file. The length of the file is 0 
bytes.


Anyone have ideas what could be causing this? I suspect it's blocking on 
something, but I can't imagine where.


There is no stderr/stdout output anywhere in the program so it's not 
blocking on anything stdio related (that I can imagine)


Thoughts?
-Sandy



--
http://mail.python.org/mailman/listinfo/python-list


Strangeness: Cannot write to a file from a process created by Windows Task Scheduler ...

2009-10-26 Thread Sandy Walsh

Hi there,

Seeing some really weird behavior and perhaps someone has seen something 
similar:


I have a python script that launches as a Windows Scheduled Task. The 
program simply opens a disk file and writes some text to it:


---
f = open("waiting.txt", "w")
x = 0
while 1:
   f.write("Sleeping: %d\r\n" % x)
   x += 1
   time.sleep(2)

f.close()
---

I've run it under my user account. I've run it as Local Account. I've 
run it via pythonw and python ... only one way works:


When I run with full credentials (not local account) and python (not 
pythonw) I get output in the file (and a CMD window appears while it's 
running). In every other combination it creates the 'waiting.txt' file, 
but doesn't write any output to the file. The length of the file is 0 bytes.


Anyone have ideas what could be causing this? I suspect it's blocking on 
something, but I can't imagine where.


There is no stderr/stdout output anywhere in the program so it's not 
blocking on anything stdio related (that I can imagine)


Thoughts?
-Sandy


<>-- 
http://mail.python.org/mailman/listinfo/python-list