asynchronous DNS resolver using asyncore - python

Is there any way to make DNS resolving using Python with asyncore?
I can not install adns and I do not like to use gevent library.
(for URL downloading gevent give me slow performance than syncore.loop)

I asked google your question, and it told me about http://subvert-rpki.hactrn.net/trunk/rpkid/rpki/adns.py which seems to be a DNS client implementation based on asyncore. So, there you have it, there is a way.

Related

Load-testing Asp.net Core SignalR using Locust

I would like to load-test a SignalR service using Locust. I found that the following library can send and receive SignalR requests: https://pypi.org/project/signalrcore/
Now, according to the Locust docs, the next step would be to write a custom client for Locust that can send SignalR requests. But there is the following warning:
Any protocol libraries that you use must be gevent-friendly (use the
Python socket module or some other standard library function like
subprocess), or your calls are likely to block the whole Locust/Python
process.
Some C libraries cannot be monkey patched by gevent, but allow for
other workarounds. For example, if you want to use psycopg2 to
performance test PostgreSQL, you can use psycogreen
I am a beginner in Python so I don't understand exactly what it means. The library "signalrcore" I am using is 100% synchronous. Does it means I can't use it with Locust?
I found an a fork of signalrcore that uses asyncio. Should I use that fork instead and just make sure all my signalr calls are non blocking?
Thanks!
SignalRCore seems to use requests and websocket-client under the hood, both of which are gevent-friendly. I cant say for sure, but I’d give it 90% probability that it will work ”out of the box” :)
If you do use the asyncio one you’d need to do some magic yourself. At least I have never combined that with gevent.

How to use pycurl with Twisted Python?

I am writing an application using pycurl, and need to make it work in Twisted. I've been searching for either making pycurl somehow compatible with Twisted framework, or using an existing Twisted library. I am suggested Twisted web, but there is no direct map of functions from pycurl to Twisted web. Can anyone point me to the right direction?
Edit: One solution is run pycurl in another thread, but preferably, I wish to use Twisted framework or pycurl that is nonblocking, so I don't have to create another thread.
For any blocking function, if there's no other asynchronous alternative, Twisted lets you run it on another thread but treat it as a Deferred.
from twisted.internet import threads
d = threads.deferToThread(pycurl.some_function)
d.addCallback(callback)
See Integrating blocking code with Twisted in Generatin Deferreds.
Have you considered using Twisted web.client.Agent? It is very basic agent, but integrates very well with the Twisted event loop.

How to receive the Events from .NET using Python

I want to consume the events/Signals exposed by the Application via .NET SignalR.
My requirement is to receive those signals using Python.
Kindly help me out.
A similar question was asked here:
Using SignalR server from Python code
There are no Python SignalR libraries available, so your only option would be to port a lightweight version of SignalR to python yourself. See https://github.com/davidfowl/SignalR.Lite
Obviously this is not a trivial undertaking!
I just wanted to offer another approach. Maybe the simpler solution would be to execute the SignalrR javascript library in python and just create a translational layer to get it back into python objects.
I do not have code proving this, but I was hoping this would encourage someone in the future to try it.

Python3: Looking for alternatives to gevent and pylibmc/python-memcached

So, I have decided to write my next project with python3, why? Due to the plan for Ubuntu to gradually drop all Python2 support within the next year and only support Python3. (Starting with Ubuntu 13.04)
gevent and the memcached modules aren't officially ported to Python3.
What are some alternatives, already officially ported to Python3, for gevent and pylibmc or python-memcached?
Circuits has now support for Python 3, try it it is great.
for memcached you probably know alternative: redis+python3
I am stuck in the same point.
Its core is greenlet 0.4.0, which is available in python 3, but not the full libraries (gevent, evenlet or concurrence).
There are some attempts to migrate it, but with no luck.
You can check packages availability in this website: http://py3ksupport.appspot.com/pypi/greenlet
If I find any alternative I would let you know.
pymemcache : A comprehensive, fast, pure-Python memcached client.
Comparison with other clients
pylibmc
The pylibmc library is a wrapper around libmemcached, implemented in
C. It is fast, implements consistent hashing, the full memcached
protocol and timeouts. It does not provide access to the "noreply"
flag. It also isn't pure Python, so using it with libraries like
gevent is out of the question, and its dependency on libmemcached
poses challenges (e.g., it must be built against the same version of
libmemcached that it will use at runtime).
Python-memcache
The python-memcache library implements the entire memcached text
protocol, has a single timeout for all socket calls and has a flexible
approach to serialization and deserialization. It is also written
entirely in Python, so it works well with libraries like gevent.
However, it is tied to using thread locals, doesn't implement
"noreply", can't treat errors as cache misses and is slower than both
pylibmc and pymemcache. It is also tied to a specific method for
handling clusters of memcached servers.

Python accessing web service protected by PKI/SSL

I need to use Python to access data from a RESTful web service that requires certificate-based client authentication (PKI) over SSL/HTTPS. What is the recommended way of doing this?
The suggestion by stribika using httplib.HTTPSConnection should work for you provided that you do not need to verify the server's certificate. If you do want/need to verify the server, you'll need to look at a 3rd party module such as pyOpenSSL (which is a Python wrapper around a subset of the OpenSSL library).
I found this: http://code.activestate.com/recipes/117004/
I did not try it so it may not work.
I would recommend using M2Crypto. If you are a Twisted guy, M2Crypto integrates with Twisted so you can let Twisted handle the networking stuff and M2Crypto the SSL/verification/validation stuff.

Categories