Twisted in the Google Summer of Code?

Sign up is sometime soon, and before considering this it'd be good to 
know we'd be able to find mentors to help the students with their 
projects. Would any developers working on Twisted be interested in being 
mentors for a student over the summer?

-Itamar
Picon
Favicon
Gravatar

How to Control Twisted Program through CLI

Hi experts,

 

I have one twisted program, and it used to connected some servers through reactor.connectTCP(),

And now, when the program is running, I want to add another connection or disconnect one connection already has through reactor.connectTCP(), how can I do that?

 

Best

Regards,

 

Xiao Peng(肖鹏)

_______________________________________________
Twisted-Python mailing list
Twisted-Python <at> twistedmatrix.com
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
Wolfgang Rohdewald | 6 Feb 22:29
Picon

safe_str is not safe

after patching CopyableFailure as written,

the stack trace now ends with the following lines. The correct
exception message is still not shown. It contains unicode chars
which reflect.py/safe_str cannot handle.

  File "/hdd/pub/src/gitgames/kajongg/src/scoringengine.py", line 170, in 
initRuleset
    raise Exception(m18n('ruleset "%1" not found', self.name))
exceptions.Exception: <Exception instance at 0x30e8b48 with str error:
 'Traceback (most recent call last):\n  File "/usr/local/lib/python2.7/dist-
packages/Twisted-11.0.0-py2.7-linux-x86_64.egg/twisted/python/reflect.py", line 
546, in _safeFormat\n    return formatter(o)\nUnicodeEncodeError: \'ascii\' 
codec can\'t encode character u\'\\u201e\' in position 10: ordinal not in 
range(128)\n'>
Unhandled error in Deferred:

after replacing safe_str by safe_repr in twisted/python/failure.py,

I finally get a meaningful printout:
  File "/hdd/pub/src/gitgames/kajongg/src/scoringengine.py", line 170, in 
initRuleset
    raise Exception(m18n('ruleset "%1" not found', self.name))
exceptions.Exception: Exception(u'Regelsatz 
\u201e55a8a17e29a1a087cc8df9cedb5590cd\u201c nicht gefunden',)
Unhandled error in Deferred:

of course a correct encoding would be even better...
my patch:

--- failure.org 2012-02-06 22:22:46.395065076 +0100
+++ failure.py  2012-02-06 22:22:51.259064816 +0100
@@ -472,7 +472,7 @@
         """Get a string of the exception which caused this Failure."""
         if isinstance(self.value, Failure):
             return self.value.getErrorMessage()
-        return reflect.safe_str(self.value)
+        return reflect.safe_repr(self.value)

     def getBriefTraceback(self):
         io = StringIO()
@@ -517,7 +517,7 @@
             w("%s: %s: %s\n" % (
                     hasFrames,
                     reflect.safe_str(self.type),
-                    reflect.safe_str(self.value)))
+                    reflect.safe_repr(self.value)))
         else:
             w( 'Traceback (most recent call last):\n')

@@ -542,7 +542,7 @@
                 w(self.type + "\n")
             else:
                 w("%s: %s\n" % (reflect.qual(self.type),
-                                reflect.safe_str(self.value)))
+                                reflect.safe_repr(self.value)))
         # chaining
         if isinstance(self.value, Failure):
             # TODO: indentation for chained failures?

--

-- 
Wolfgang
Wolfgang Rohdewald | 6 Feb 21:07
Picon

CopyableFailure fails

Hi, 

with twisted 11.0.0 and python 2.7, my error fails here:

  File "/usr/local/lib/python2.7/dist-packages/Twisted-11.0.0-py2.7-linux-
x86_64.egg/twisted/spread/pb.py", line 407, in getStateToCopy
    state['value'] = str(self.value) # Exception instance
exceptions.UnicodeEncodeError: 'ascii' codec can't encode character u'\u201e' 
in position 10: ordinal not in range(128)

this bug hides my own bug, giving me no useful backtrace.

simple fix:

--- x   2012-02-06 21:05:33.907228573 +0100
+++ pb.py       2012-02-06 21:05:36.923228461 +0100
@@ -404,7 +404,7 @@
         if isinstance(self.value, failure.Failure):
             state['value'] = failure2Copyable(self.value, 
self.unsafeTracebacks)
         else:
-            state['value'] = str(self.value) # Exception instance
+            state['value'] = repr(self.value) # Exception instance
         if isinstance(self.type, str):
             state['type'] = self.type
         else:

--

-- 
Wolfgang
Jonathan Lange | 6 Feb 16:48
Gravatar

Running Twisted tests with testtools

Hello,

I'm the nominal maintainer of Trial. I'm also an active maintainer of
testtools[1].

testtools is, roughly speaking, a base TestCase that works across a
bunch of Pythons and has a few nice features[2]. I started to prefer
it over Twisted's TestCase some time ago, and now use it pretty
consistently, even for my Twisted code.

testtools has a way of letting you run tests within the Twisted
reactor, without needing to use a particular base class. For example::

  class MyTests(TestCase):
    run_tests_with = AsynchronousDeferredRunTest

    def test_foo(self):
      ...
      return some_deferred

Or::

  class MyTests(TestCase):
    def test_ordinary_thing(self):
      ...
    @run_test_with(AsynchronousDeferredRunTest)
    def test_twisted_thing(self):
      ...
      return some_deferred

It doesn't behave exactly the way Trial does. Freed from backwards
compatibility constraints, I tightened up the implementation quite a
bit. There are options to make it emulate Trial's behaviour[3].

The documentation says that it's "highly experimental". This is not
strictly true any more, as it has been used in numerous projects and
has been found to be quite robust.

The key source code is at::
  http://bazaar.launchpad.net/~testtools-committers/testtools/trunk/view/head:/testtools/deferredruntest.py
  http://bazaar.launchpad.net/~testtools-committers/testtools/trunk/view/head:/testtools/_spinner.py

And you can get the code from PyPI or Launchpad[4].

testtools has had this feature for some time now. It's past time that
I officially informed the Twisted community about it. That's the main
reason for this email.

In my ideal world, Twisted's TestCase would inherit from testtools's
TestCase and would continue to provide the same API it does today.
This might not be everyone else's ideal though, and the path from here
to there is unclear to me. I welcome your thoughts.

cheers,
jml

[1] http://testtools.rtfd.org ; http://pypi.python.org/pypi/testtools
[2] http://testtools.readthedocs.org/en/latest/overview.html
[3] http://testtools.readthedocs.org/en/latest/for-test-authors.html#twisted-support
[4] bzr branch lp:testtools
exarkun | 5 Feb 06:05

Weekly Bug Summary

Bug summary ______________________ Summary for 2012-01-29 through 2012-02-05 Opened Closed Total Change Enhancements: 5 0 800 +5 Defects: 2 2 522 +0 Tasks: 0 2 70 -2 Regressions: 0 0 3 +0 Total: 7 4 1395 +3 |== Type Changes |== Priority Changes |== Component Changes |Defect: +0 |Normal: +3 |Core: -1 |Enhancement: +5 |Names: +4 |Task: -2 |Release Management: +1 |Web: -1
Total Tickets Open Tickets
New / Reopened Bugs ______________________ ===== Normal ===== [#5466] Howto indexes are broken, and we need more links to them (opened by itamar) defect release management http://twistedmatrix.com/trac/ticket/5466 [#5467] Fix BindAuthority For Bind files with Absolute Names (opened by BobNovas) enhancement names http://twistedmatrix.com/trac/ticket/5467 [#5468] Add port parameter to DNS Secondary Server setup (opened by BobNovas) enhancement names http://twistedmatrix.com/trac/ticket/5468 [#5469] Howto on debugging Twisted applications (opened by itamar) enhancement core http://twistedmatrix.com/trac/ticket/5469 [#5470] Fix BindAuthority's parsing of a bind zone file (opened by BobNovas) enhancement names http://twistedmatrix.com/trac/ticket/5470 [#5471] Add necessary but missing connectionLost method to client.Resolver (opened by BobNovas) enhancement names http://twistedmatrix.com/trac/ticket/5471 [#5472] Delayed calls in the sufficiently distant future break epoll reactor (opened by exarkun) defect core http://twistedmatrix.com/trac/ticket/5472 Closed Bugs ______________________ ===== Normal ===== [#4896] twisted.web.util.formatFailure vulnerable to XSS in rare cases (opened by ivank, closed by exarkun, fixed) defect web http://twistedmatrix.com/trac/ticket/4896 [#1510] abstract.py's writeSequence implementation accepts unicode (opened by exarkun, closed by exarkun, duplicate) defect core http://twistedmatrix.com/trac/ticket/1510 [#4148] Remove deprecated stuff in twisted/internet/address.py (opened by thijs, closed by thijs, duplicate) task core http://twistedmatrix.com/trac/ticket/4148 [#5235] Expand point 3.13 of the FAQ (opened by mathias, closed by thijs, fixed) task core http://twistedmatrix.com/trac/ticket/5235 Ticket Lifetime Stats ______________________ Oldest open ticket - [#50] conch command-line client doesn't work in win32 (since 2003-07-12 16:41:06). Newest open ticket - [#5472] Delayed calls in the sufficiently distant future break epoll reactor (since 2012-02-02 11:03:10). Mean open ticket age: 1134 days, 10:28:43.934140. Median: 1006 days, 5:50:43.768549. Standard deviation: 806 days, 14:36:52.441170. Interquartile range: 1331 days, 23:17:22. Mean time between ticket creation and ticket resolution: 722 days, 5:16:50.554775. Median: 159 days, 1:48:09. Standard deviation is 940 days, 15:06:06.106210. The interquartile range is 1331 days, 1:40:43. Mean time spent in review: 88 days, 23:49:38.765913. Median: 4 days, 10:03:11. Standard deviation: 364 days, 14:05:40.758653. Interquartile range: 16 days, 11:23:10. Mean number of times a ticket is reviewed: 1.97169325785. Median: 1 Standard deviation: 1.57656589628. Interquartile range: 1. Contributor Stats ______________________ In the last 4 weeks, 10 unique ticket reporters 7 unique ticket reviewers 5 unique ticket resolvers In the last 24 weeks, 63 unique ticket reporters 20 unique ticket reviewers 13 unique ticket resolvers In the last 48 weeks, 124 unique ticket reporters 33 unique ticket reviewers 26 unique ticket resolvers
_______________________________________________
Twisted-Python mailing list
Twisted-Python <at> twistedmatrix.com
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
moses dsouza | 4 Feb 08:37
Picon

regarding #5412

Hi

Is this #5412 valid ? I ask because there aren't any comments against this bug. I'll provide a patch on confirmation.

regards
moijes12

_______________________________________________
Twisted-Python mailing list
Twisted-Python <at> twistedmatrix.com
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
月忧茗 | 3 Feb 02:43
Picon
Gravatar

help me on startService ( service.Service )

Hi, all 

I'm a new guy for twisted, 
I just study the example of finger14.tac

But,  startService not called when program running.


Please help,  thanks.


Code like bellow:


class FingerService(service.Service):

...
def startService(self):

print 'start service'
self.test_call()
service.Service.startService(self)



Noting output ,and test_call()  not called.
_______________________________________________
Twisted-Python mailing list
Twisted-Python <at> twistedmatrix.com
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
Tenth | 1 Feb 18:09
Gravatar

February Twisted Sprint

Itamar has generously offered to host this month's Boston Twisted Sprint!


Thus it will be happening at his place, near Porter Square, on Saturday, February 11th, from 1:00 PM to 9:00 PM.

An evite has gone out to the usual suspects, but if you'd like to be added (or removed from) that list, or would like more information about this or other Boston Sprints, let me know!

Thanks,

- Dave
_______________________________________________
Twisted-Python mailing list
Twisted-Python <at> twistedmatrix.com
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
Benjamin Rutt | 1 Feb 04:59
Picon
Gravatar

how to ensure writes to stdout via stdio.StandardIO are completed before we shutdown the reactor?

Hi twisted community,

What’s the best way to ensure writes to stdout via stdio.StandardIO
are completed before we shutdown the reactor?   The use case is to
emit an error message before we shutdown the reactor and stop our
program.  Dummy code snippet:

--------------------------------------------
#!/usr/bin/python

from twisted.internet import reactor, stdio
from twisted.protocols.basic  import LineReceiver

class StdinInteractor(LineReceiver):
  delimiter = '\n'

def go():
  stdio_proto = StdinInteractor()
  stdio.StandardIO(stdio_proto)
  stdio_proto.transport.write('did we get this message?\n')
  if 0:
    reactor.stop()
  else:
    reactor.callLater(1.0, reactor.stop)

reactor.callWhenRunning(go)
reactor.run()
--------------------------------------------

If I change ‘if 0’ to ‘if 1’, I don’t get the message on stdout.  The
‘reactor.callLater(1.0, reactor.stop)’ is obviously a hack to let the
reactor send out the buffered message before shutting down.  Any
ideas?

Thanks,

--

-- 
Benjamin Rutt
Laurens Van Houtven | 31 Jan 13:41
Gravatar

Twisted Sprint at PyCon 2012 -- please sign up!

Hey!



So, I volunteered to manage the sprint at PyCon 2012. Since no-one else has, I'm moving forward assuming I got the job ;-)

You should sign up (which involves logging in on the PyCon site, scrolling to the bottom, clicking "Edit" and adding your name) to the sprint. This makes it easier for organizers to know how many people to expect where.

Here's the signup link:



cheers
lvh

_______________________________________________
Twisted-Python mailing list
Twisted-Python <at> twistedmatrix.com
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python

Gmane