Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8938865
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T10:43:37+00:00 2026-06-15T10:43:37+00:00

I’m using PyBluez to connect to a device through bluetooth. It is working just

  • 0

I’m using PyBluez to connect to a device through bluetooth. It is working just fine. The device is using SPP and I connect using a BluetoothSocket (RFCOMM).

Basic interaction is: Send init command -> receive confirmation; send start command -> receive continuous data; send stop command -> …

I need to be able to control the application from another app: starting, stopping … I was thinking ZeroMQ or maybe Tornado and a HTTP/REST ifc.

I’m not very keen on making this a multi-threaded app, as I believe it to be a bit over-kill. I’ve worked a lot with threads and pools of them in C#/.NET, but I have a hunch it is not really necessary here. On the contrary, I think it will be quite messy.

However, I need to be able to process commands (e.g. “start”, “stop”) via ZeroMQ/REST/ … while continosly receiving data and sending the occasional packet.

As I am very new to Python I am not sure how to implement this. I have a few ideas: Can the BluetoothSocket be hooked up to the ZeroMQ/Tornado IOLoop?

I assume I can accomplish almost anything using Twisted, but I don’t really need everything that Twisted provides. If I need to pull in Twisted, I’ll do it. I’ve actually found a Twisted implementation of BluetoothSocket. But again, do I need Twisted?

I’ve tried using the Tornado IOLoop. No exceptions are thrown, but on the other hand no data is being received or sent:

def eventhandler(s, events, error = None):
    if events & ioloop.IOLoop.READ:
        print 'Socket read: %r' % s.recv(1024)
    elif events & ioloop.IOLoop.ERROR:
        print 'Socket error!'

events = ioloop.IOLoop.READ | ioloop.IOLoop.ERROR
self._loop.add_handler(self._socket.fileno(), eventhandler, events)

I don’t really know what I’m doing right now. I’ll find a way eventually, but need a hint on which direction to go.

Extensive Google-fu hasn’t turned up much useful information, so I’m asking here now.

Edit: I’m currently looking at “gevent”. Seems simpler than Twisted at least.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T10:43:38+00:00Added an answer on June 15, 2026 at 10:43 am

    You should just use Twisted. Your real question seems to be about Twisted’s size and resource utilization; whether you will pay an unreasonable cost in your application for using it, whether in terms of API complexity, memory, package size on disk, deployment hassles, or conflicts with other libraries you might want to use.

    You won’t.

    1. API complexity: Twisted’s API is straightforward. Contrary to certain FUD, you don’t need to learn thousands of APIs to use it effectively: the core of Twisted has a quite lean API, which has several discrete layers and many explicitly documented formal interfaces between each layer. If you know what you want to know (and it seems like you do), with a little guidance you can easily pick it up. Also, as a mature project, there are plenty of people in the community who can help your users come up to speed.
    2. Memory usage: Twisted has always been very careful to manage its run-time dependencies, and to only import what it needs. Loading the reactor won’t load the IMAP implementation, so just import what you need and don’t worry about it.
    3. Package size: Twisted is two megabytes. Furthermore, if you’re using any popular UNIX-y OS (Linux, OS X, FreeBSD), you’ve probably got an operating system package of Twisted already. On many distributions it’s even installed already.
    4. Deployment hassles: if you’re going to worry about any problem, this is the one to think about, but the issues related to deployment are really very minor. “pip install Twisted” works fine (right now, as long as you have a C compiler). Twisted works with py2exe, py2app, and Debian packaging to the extent that anything in Python does. Really, the only thing anybody ever has any issues with is the plugin system, and for many applications you can just ignore that.
    5. Library conflicts: You will be totally fine. Twisted goes out of its way to be compatible with every hare-brained idea that any other event loop library ever came up with, whether it’s GUIs or event loops. You want to use ZMQ? Go for it. Tornado? Sure, whatever; and the integration goes both ways. Tornado itself supports such integration. Want to use a blocking library from Twisted, but you’re on the main thread and you don’t want to block? deferToThread has got you covered. Want to use a Twisted function from a blocking library, and you need to block? Okay, just make a blocking call from a thread.

    I hope this clears up any misconceptions you might have had about Twisted being “overkill”.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am reading a book about Javascript and jQuery and using one of the
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
We're building an app, our first using Rails 3, and we're having to build
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We are using XSLT to translate a RIXML file to XML. Our RIXML contains

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.