Re: [Twisted-Python] Does anyone use ampoule in production?

2011-11-21 Thread Žiga Seilnacht
On 21.11.2011 8:40, gelin yan wrote:
> Hi glyph
>
>   I attached a file for this purpose. there is a number 4073 inside the
> code. when i use any smaller value, the function return a correct result. I
> use win 7&  twisted 11.1 at the moment. I am not sure whether this limit
> comes from os or not.
>
> thanks
>
> gelin yan
>

That sounds like issue 5365:
http://twistedmatrix.com/trac/ticket/5365

Does the patch there fix the issue for you?

Best regards,
Ziga

___
Twisted-Python mailing list
Twisted-Python@twistedmatrix.com
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python


Re: [Twisted-Python] server issues; SVN in read-only, but Trac isn't

2011-07-09 Thread Žiga Seilnacht
On 6.7.2011 21:58, exar...@twistedmatrix.com wrote:
>
> Thanks for pointing this out.  I think James has fixed the issue.
>
> Jean-Paul
>

Great, thanks!

Regards,
Ziga

___
Twisted-Python mailing list
Twisted-Python@twistedmatrix.com
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python


Re: [Twisted-Python] server issues; SVN in read-only, but Trac isn't

2011-07-05 Thread Žiga Seilnacht
On 5.7.2011 1:49, James Y Knight wrote:
>
> On Jul 4, 2011, at 7:06 PM, Glyph Lefkowitz wrote:
>
>>  Hello from the Twisted server operations team,
>>
>>  The Twisted SVN server has run into some minor unexpected trouble during 
>> routine system maintenance.  For now, SVN is in read-only mode.  However, 
>> this shouldn't affect Trac, so feel free to keep doing reviews and 
>> submitting patches in the meanwhile.  Hopefully many of you are working from 
>> DVCS mirrors and will hardly notice the interruption :-).
>>
>>  We will send another notice as soon as things are back to normal.
>
> I believe it should be functional now. Please advise if anything seems 
> broken. :)
>
> James
>

Hello,

It looks like the subversion commit mails to twisted-comm...@twistedmatrix.com
list are not getting through for about a day. It would be great if they could
be restored, I find them convenient to keep up with the Twisted development.

Regards,
Ziga

___
Twisted-Python mailing list
Twisted-Python@twistedmatrix.com
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python


Re: [Twisted-Python] Gtk2Reactor: what are the reasons for avoiding GLib functions?

2011-04-05 Thread Žiga Seilnacht
Hello,

On 5.4.2011 9:08, Jason Heeris wrote:
> I'd like to try and get to the bottom of the various problems with
> Twisted + GTK + Windows (mainly issue #4932[1], but see also issues
> #4376[2], #4862[3], #1759[4]).
>
> On issue #4376 there's a comment from Exarkun:
>
> "glib handles timeouts much less efficiently than any of the existing
> Twisted reactors. Letting glib take care of these would probably make
> the glib-based reactors unusable for applications with many timeouts."
>
> Is there a benchmark or piece of code somewhere that verifies this (or
> at least gives some sort of demonstration of "unuseable")?
>

I think that the main reason for PortableGtkReactor being used on Windows
is due to glib's IO channels limitations on Windows. You can only have 63
channels in the event loop at the same time due to g_poll's use of
MsgWaitForMultipleObject.

In addition, IO channels are quite buggy on Windows when used for sockets,
see the comment at the top of the glib/giowin32.c file in the glib source
for a list of issues. E.g. I suspect that the second problem described in:

https://bugzilla.gnome.org/show_bug.cgi?id=357674

is responsible for Twisted's ticket #3371, because a similar problem
can be seen with win32eventreactor (ticket #4950), which also uses
WSAEventSelect for socket monitoring.

Best regards,
Ziga

___
Twisted-Python mailing list
Twisted-Python@twistedmatrix.com
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python


Re: [Twisted-Python] Twisted Names - strange RuntimeError

2011-01-09 Thread Žiga Seilnacht
On 9.1.2011 16:47, Angelo Dell'Aera wrote:
> On Sun, 09 Jan 2011 14:54:33 -
> exar...@twistedmatrix.com wrote:
>
>>  On 01:54 pm, ita...@itamarst.org wrote:
>>  >On Sun, 2011-01-09 at 12:10 +0100, Angelo Dell'Aera wrote:
>>  >>Hi,
>>  >>while developing a code based on Twisted Names I'm finding myself
>>  >>catching
>>  >>RuntimeErrors like the one reported below.
>>  >
>>  >It seems like someone, somewhere is doing a startWriting() (or
>>  >pauseProducing) on the Port object, i.e. the transport of the
>>  >DatagramProtocol. Do you have any code that does
>>  >startWriting/pauseProducing? I don't see any in twisted.internet.udp or
>>  >twisted.names.
>>
>>  Perhaps an easy way to track this down would be to make
>>  udp.Port.startWriting raise an exception.  Perhaps that's even what it
>>  should do in Twisted itself.
>
> Jean-Paul,
> I can try adding the startWriting method and see what happens if needed. If
> you need additional details from such exception in order to better track
> down the issue please let me know and I'll be glad to add everything.
>
> Thanks and cheers,

Could you also let us know which operating system and version you are
using and which reactors you tried? A similar error was recently reported
for poll reactor on FreeBSD (http://twistedmatrix.com/trac/ticket/4759).

Regards,
Ziga

___
Twisted-Python mailing list
Twisted-Python@twistedmatrix.com
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python


Re: [Twisted-Python] Unable to start twistd service on Ubuntu 10.04 when using pseudo terminal

2010-09-30 Thread Žiga Seilnacht
Hello,

Garret Heaton wrote:
> I've simplified this issue down and am able to reproduce it without
> Twisted: http://gist.github.com/603154
> 
> Still not sure what the cause is, so if anyone has any ideas I'd love to
> hear them. Thanks!
> 

The behavior that you are seeing seems to be related to the change in
the 2.6.32 kernel, where they changed the child-runs-first scheduler
parameter to false. Setting that parameter to 1 with:

$ sudo sysctl -w kernel.sched_child_runs_first=1

and rebooting the computer restores the behavior that you saw on the
old kernel for me. See http://lwn.net/Articles/352863/ for more details.

Parent (which is the controlling process when ran with -t) exiting before
the child starts causes the child to receive SIGHUP signal immediately as
it starts running, before it has time to disassociate itself from the
parent's process group. It seems to me that this might be an actual bug
in twistd, it should block the SIGHUP signal across the fork() calls.

Your test program has an additional assumption that the child will run
before the parent; the child in your program tries to write to stdout,
i.e. the controlling terminal, which gets closed once the parent exits.

The modified test program below works for me regardless of the setting
of the kernel.sched_child_runs_first parameter.

Hope this helps,
Ziga



import os
import signal

f = open("test_fork.out", "w")

def daemonize():
 # See http://www.faqs.org/faqs/unix-faq/programmer/faq/ - Section 1.7
 print >> f, '--- %s: daemonizing' % os.getpid()

 signal.signal(signal.SIGHUP, signal.SIG_IGN)
 if os.fork(): # launch child and...
 print >> f, '--- %s: kill parent 1' % os.getpid()
 os._exit(0) # kill off parent
 print >> f, '--- %s: old sid: %r' % (os.getpid(), os.getsid(os.getpid()))
 os.setsid()
 print >> f, '--- %s: new sid: %r' % (os.getpid(), os.getsid(os.getpid()))
 if os.fork(): # launch child and...
 print >> f, '--- %s: kill parent 2' % os.getpid()
 os._exit(0) # kill off parent again.

 signal.signal(signal.SIGHUP, signal.SIG_DFL)
 print >> f, '--- %s: daemonizing done' % os.getpid()

if __name__ == "__main__":
 print >> f, 'starting as %d' % os.getpid()
 daemonize()
 print >> f, 'stopping as %s' % os.getpid()




___
Twisted-Python mailing list
Twisted-Python@twistedmatrix.com
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python


Re: [Twisted-Python] Twisted 10.1.0pre1 released -- please test!

2010-06-25 Thread Žiga Seilnacht
Hello,

Kevin Horn wrote:
> Running trial with the --unclean-warnings flag, I get only 3 failures.
> Attached.
> 
> Kevin Horn
> 

These errors seem to be caused by your deep directory hierarchy, resulting
in trial hitting the MAX_PATH limit. Could you try unpacking the tarball
in the root of your drive and rerunning the tests?

Regards,
Ziga

___
Twisted-Python mailing list
Twisted-Python@twistedmatrix.com
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python


Re: [Twisted-Python] Twisted 9.0.0?

2010-03-04 Thread Žiga Seilnacht
exar...@twistedmatrix.com wrote:
> On 07:54 pm, ziga.seilna...@gmail.com wrote:
>>
>>I think that easy_install and related tools can be directed to the
>>proper download location by providing a Download-URL on the PyPI page.
>>
>>E.g. the page for Twisted 9.0.0:
>>http://pypi.python.org/pypi/Twisted/9.0.0
>>
>>should have a Download-URL link to:
>>http://tmrc.mit.edu/mirror/twisted/Twisted/9.0/
> 
> That's easy enough to adjust.  There.  Someone want to try it and see if 
> it works?
> 
> Jean-Paul
> 

It looks like it works now:

I:\> easy_install Twisted==9.0.0
Searching for Twisted==9.0.0
Reading http://pypi.python.org/simple/Twisted/
Reading http://www.twistedmatrix.com
Reading http://twistedmatrix.com/products/download
Reading http://twistedmatrix.com/projects/core/
Reading http://twistedmatrix.com/
Reading http://tmrc.mit.edu/mirror/twisted/Twisted/9.0/
Best match: Twisted 9.0.0
Downloading 
http://tmrc.mit.edu/mirror/twisted/Twisted/9.0/Twisted-9.0.0.win32-py2.5.exe

Now, how to get rid of the egg yolk...

Regards,
Ziga

___
Twisted-Python mailing list
Twisted-Python@twistedmatrix.com
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python


Re: [Twisted-Python] Twisted 9.0.0?

2010-03-04 Thread Žiga Seilnacht
Glyph Lefkowitz wrote:
> On Mar 4, 2010, at 7:59 AM, Jonathan Lange wrote:
>> On Thu, Mar 4, 2010 at 10:45 AM, Mark van Lent 
>>  wrote:
>>> Hi everyone! I am a bit puzzled about the way new version of
>>> Twisted is released. Or better: the way the old version seems to
>>> be taken out of service. Last weeks I've been developing agains
>>> version Twisted 9.0.0. Yesterday I wanted to deploy my code to my
>>> production server, but to my surprise I could not easy_install
>>> that version anymore: $ easy_install Twisted==9.0.0 Searching for
>>> Twisted==9.0.0 Reading http://pypi.python.org/simple/Twisted/ 
>>> Reading http://www.twistedmatrix.com Reading
>>> http://twistedmatrix.com/products/download Reading
>>> http://twistedmatrix.com/projects/core/ Reading
>>> http://twistedmatrix.com/ No local packages or download links
>>> found for Twisted==9.0.0 Best match: None (Okay, actually I'm
>>> using buildout to setup my environment, but the above 
>>> demonstrates my problem more clearly.) I'm sure the new version
>>> of Twisted is better and improved but I still wonder why version
>>> 9.0.0 has effectively been decommissioned. Or am I missing
>>> something and is it still possible to easy_install version 9.0.0?
>>> 
>> 
>> It's an oversight.
> 
> I think it's actually a bug in easy_install, or at least a
> mis-design.
> 
> To make something easy_installable, you don't provide structured
> information in PyPI; there may be a way to do that, but most packages
> I've seen (Twisted included) just provide a link to a page which then
> provides a link to a file with a filename of vaguely the appropriate
> shape.  easy_install works by screen-scraping that link.
> 
> In our case, the "home page", http://twistedmatrix.com, links
> directly to a Twisted-.tar.bz2, which is then used.
> 
> If someone (perhaps Mark van Lent!) could point us at how to provide
> the correctly structured information to easy_install via PyPI so it
> will _stop_ screen-scraping our website, and just point at the
> correct files, this problem could be addressed.
> 

I think that easy_install and related tools can be directed to the
proper download location by providing a Download-URL on the PyPI page.

E.g. the page for Twisted 9.0.0:
http://pypi.python.org/pypi/Twisted/9.0.0

should have a Download-URL link to:
http://tmrc.mit.edu/mirror/twisted/Twisted/9.0/

Regards,
Ziga


___
Twisted-Python mailing list
Twisted-Python@twistedmatrix.com
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python


Re: [Twisted-Python] Daemon processes on windows

2009-11-08 Thread Žiga Seilnacht

Brian Granger wrote:

Fantastic, thanks for sharing this code.  I will definitely have a look.  If
it turns out to
work for us, would you mind releasing this under a BSD license so we can
include
it in IPython (BSD open source project)?  In either case, the ideas will be
very helpful to us.

Cheers,

Brian



Sure, you can find a slightly updated version of the code in the 
attachment, licensed under the two clause BSD license and without the 
syntax error.


It would be even better if you could try to integrate the functionality 
into Twisted itself, if the core developers agree that it would be 
useful. I opened a ticket for this:


http://twistedmatrix.com/trac/ticket/4073

Regards,
Ziga
# Copyright (c) 2009 Ziga Seilnacht. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice,
#this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright notice,
#this list of conditions and the following disclaimer in the documentation
#and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE FREEBSD PROJECT ''AS IS'' AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
# EVENT SHALL THE FREEBSD PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 
OF
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 
NEGLIGENCE
# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


import os
import sys
import msvcrt

try:
import win32con
import win32process
import win32security
import win32service
except ImportError:
win32process = None

from twisted.python import win32



def getPythonArgs():
"""
Return the list of command line args that were used to start
the current Python interpreter and were not stored in C{sys.argv}.

These are the options that control the Python interpreter itself,
like the Python executable, optimization level, warning filters,
division behaviour and literal string handling.
"""
args = [sys.executable]
for warnoption in sys.warnoptions:
args.append("-W")
args.append(warnoption)
if type(1 / 2) is not int:
args.append("-Qnew")
if type("") is not str:
args.append("-U")
if not __debug__:
if getPythonArgs.__doc__ is None:
args.append("-OO")
else:
args.append("-O")
return args



def daemonize():
args = [os.path.abspath(__file__)] + sys.argv
executable = sys.executable
cmdline = win32.quoteArguments(getPythonArgs() + args)
inherit = False
priority = win32process.GetPriorityClass(win32process.GetCurrentProcess())
flags = (win32process.CREATE_BREAKAWAY_FROM_JOB | # session leader
 win32process.CREATE_NEW_PROCESS_GROUP |  # group leader
 win32process.DETACHED_PROCESS |  # no controlling terminal
 priority)
info = win32process.STARTUPINFO()
win32process.CreateProcess(executable, cmdline, None, None,
   inherit, flags, None, None, info)
# Do what exec* functions do, let the OS do the cleanup.
os._exit(0)



def daemonize2():
args = [sys.argv[1], "--nodaemon"] + sys.argv[2:]
executable = sys.executable
cmdline = win32.quoteArguments(getPythonArgs() + args)
inherit = True
priority = win32process.GetPriorityClass(win32process.GetCurrentProcess())
flags = (win32process.CREATE_NO_WINDOW | # create an invisible console
 win32process.CREATE_NEW_PROCESS_GROUP | # group leader
 priority)
attributes = win32security.SECURITY_ATTRIBUTES()
attributes.bInheritHandle = True
station = win32service.CreateWindowStation(None, 0,
   win32con.GENERIC_READ |
   win32con.GENERIC_WRITE,
   attributes)
station.SetProcessWindowStation()
sname = win32service.GetUserObjectInformation(station,
  win32service.UOI_NAME)
dname = str(os.getpid())
desktop = win32service.CreateDesktop(dname, 0,
 win32con.GENERIC_READ |
 win32con.GENERIC_WRITE,
 attributes)
desktop.SetThreadDesktop()
null =

Re: [Twisted-Python] Daemon processes on windows

2009-11-07 Thread Žiga Seilnacht
Brian Granger wrote:
> Hi,
> 
> I have a server-like process that uses twisted.  I need it to daemonize
> itself and on linux/os x I am simply
> using the daemonize function from twistd.  This works fine.  What about
> Windows thoughI saw that the
> win32 version of twistd doesn't have (unless I am missing it) the ability to
> daemonize a process.
> 
> Is is simply impossible to daemonize a process on windows?  If so, is there
> any way to have a child
> process on windows ignore SIGINT send to the parent?
> 
> Cheers and thanks,
> 
> Brian
> 

It is possible to daemonize a process on Windows. I experimented with 
adding that support to the twistd script, but got swamped with other 
work and couldn't finish it. Below is the code that I have so far. You 
can save it in a module and call the daemonize() function from your script.

The process of daemonization is similar to the one on UNIX -- you have 
to spawn a child process twice, the first child is responsible for 
breaking away from any job objects (somewhat similar to becoming a 
session leader on UNIX), becoming a new process group leader and closing 
all handles (file descriptors) that might have been inherited.

The second child has to open dummy std* files and a new (hidden) 
console, otherwise the signals stop working. There is a slight 
complication with window stations and desktops. Each console creates at 
least one window and some other user objects, so we have to create
a separate desktop, or other processes would be able to manipulate them 
  and send us arbitrary (Windows) messages.

Regards,
Ziga



import os
import sys
import msvcrt

import win32con
import win32process
import win32security
import win32service

from twisted.python import win32



def getPythonArgs():
 """
 Return the list of command line args that were used to start
 the current Python interpreter and were not stored in C{sys.argv}.

 These are the options that control the Python interpreter itself,
 like the Python executable, optimization level, warning filters,
 division behaviour and literal string handling.
 """
 args = [sys.executable]
 for warnoption in sys.warnoptions:
 args.append("-W")
 args.append(warnoption)
 if type(1 / 2) is not int:
 args.append("-Qnew")
 if type("") is not str:
 args.append("-U")
 if not __debug__:
 if getPythonArgs.__doc__ is None:
 args.append("-OO")
 else:
 args.append("-O")
 return args



def daemonize():
 args = [os.path.abspath(__file__)] + sys.argv
 executable = sys.executable
 cmdline = win32.quoteArguments(getPythonArgs() + args)
 inherit = False

 flags = (win32process.CREATE_BREAKAWAY_FROM_JOB | # session leader
  win32process.CREATE_NEW_PROCESS_GROUP |  # group leader
  win32process.DETACHED_PROCESS) # no controlling terminal

 info = win32process.STARTUPINFO()
 win32process.CreateProcess(executable, cmdline, None, None,
inherit, flags, None, None, info)
 # Do what exec* functions do, let the OS do the cleanup.
 os._exit(0)



def daemonize2():
 args = [sys.argv[1], "--nodaemon"] + sys.argv[2:]
 executable = sys.executable
 cmdline = win32.quoteArguments(getPythonArgs() + args)
 inherit = True
 # create an invisible console
 flags = (win32process.CREATE_NO_WINDOW
 attributes = win32security.SECURITY_ATTRIBUTES()
 attributes.bInheritHandle = True
 station = win32service.CreateWindowStation(None, 0,
win32con.GENERIC_READ |
win32con.GENERIC_WRITE,
attributes)
 station.SetProcessWindowStation()
 sname = win32service.GetUserObjectInformation(station,
   win32service.UOI_NAME)
 dname = str(os.getpid())
 desktop = win32service.CreateDesktop(dname, 0,
  win32con.GENERIC_READ |
  win32con.GENERIC_WRITE,
  attributes)
 desktop.SetThreadDesktop()
 null = os.open("NUL", os.O_RDWR)
 handle = msvcrt.get_osfhandle(null)
 info = win32process.STARTUPINFO()
 info.lpDesktop = "%s\\%s" % (sname, dname)
 info.dwFlags = win32process.STARTF_USESTDHANDLES
 info.hStdInput = info.hStdOutput = info.hStdError = handle
 win32process.CreateProcess(executable, cmdline, None, None,
inherit, flags, None, None, info)
 # Same as above, exit as fast as possible.
 os._exit(0)



if __name__ == "__main__":
 daemonize2()

___
Twisted-Python mailing list
Twisted-Python@twistedmatrix.com
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python