4 ms·
Twisted doesn't support Python 3, which is problematic for some projects. I've also always found the code it produces difficult to test.
by richardwhiuk 8y ago
Twisted doesn't support Python 3, which is problematic for some projects. I've also always found the code it produces difficult to test.
- jMyles 8y ago> Twisted doesn't support Python 3 No no, it now supports Python 3 wonderfully. It took a very long time, because a lot of what Twisted does was more dramatically changed from 2-3 than a lot of projects. Consider, for example, the implications of PEP-3333, which required that headers be in the native str type in Python 2, but also the native str type (ie, unicode) in Python 3. This was a tough problem. [0] However, those days are long behind us. Not only does Twisted support Python 3, but it can interchange its own flow control (ie, the reactor) with the asyncio event loop, and also convert (and ensure) that Futures and Deferreds fire in a way that is cross-compatible. You can also use the inlineCallback decorator to see all of the new coroutine syntactic sugar. Here's a project I'm working on right now that is Python 3.6+ with Twisted: https://github.com/nucypher/nucypher/ https://github.com/nucypher/nucypher/ > I've also always found the code it produces difficult to test. Yeah, I hear that a lot, and for my part, I've just never had that trouble, so I'm not sure how to respond. Have you ever read the "TDD with Twisted" document[1]? Also, the new pytest-twisted tooling helps quite a bit if you're using pytest. 0: https://github.com/twisted/twisted/blob/6ac66416c0238f403a8dc1d42924fb3ba2a2a686/src/twisted/web/wsgi.py#L26 https://github.com/twisted/twisted/blob/6ac66416c0238f403a8d... 1: https://twistedmatrix.com/documents/current/core/howto/trial.html https://twistedmatrix.com/documents/current/core/howto/trial...
- limaoscarjuliet 8y agoBTW, when writing in Twisted use @inlineCallbacks with yields for async code. The code reads as if it was synchronous then. @inlineCallbacks def get_index_status(self, index_id): uri = "{}/index-status?id={}".format(self.SERVER, index_id) #yes, no escaping, as this is silly test only r = yield self.get(uri) returnValue(r.text) Using raw Deferreds is a big more difficult.
- richardwhiuk 8y agohttps://twistedmatrix.com/trac/query?status=assigned&status=new&status=reopened&group=status&milestone=Python-3.x https://twistedmatrix.com/trac/query?status=assigned&status=... suggests this isn't done - is that incorrect?
- deleted 8y ago[deleted]
- limaoscarjuliet 8y agoI've pushed Twisted on a 100M US company about 7 years ago and it has continued to work for us big time. The code - tens of thousands of lines in 20+ servers - survived Twisted upgrades for all these years without any changes (OK, there was one related to import, had to add PYTHONPATH=. to env). Kudos to Twisted team!
- deleted 8y ago[deleted]