1

I'm writing an application that sends files over network, I want to develop a custom protocol to not limit myself in term on feature richness (http wouldn't be appropriate, the nearest thing is the bittorrent protocol maybe).

I've tried with twisted, I've built a good app but there's a bug in twisted that makes my GUI blocking, so I've to switch to another framework/strategy.

What do you suggest? Using raw sockets and using gtk mainloop (there are select-like functions in the toolkit) is too much difficult?

It's viable running two mainloops in different threads?

Asking for suggestions

pygabriel
  • 9,840
  • 4
  • 41
  • 54
  • 1
    If you have a twisted app that mostly works... why not just fix it? It's definitely possible to write twisted applications with responsive GUIs. Are you certain throwing away working code is the right answer? – Rakis Jun 07 '10 at 18:03
  • The problem is in twisted, not in my app, I'm sorry, I've just noticed that is not clear what I meant, in particular the bug is that: http://twistedmatrix.com/trac/ticket/4489 – pygabriel Jun 07 '10 at 19:02
  • Ah. That'd do it. Short of switching GUI toolkits or diving in and trying to fix the twisted reactor yourself (the select reactor isn't too bad, dunno about gtk though)... it certainly might be worth starting fresh. – Rakis Jun 07 '10 at 19:29
  • Unfortunately all the other GUI toolkits (tested on wx, qt, tk) fails in the same way. Tt seems to be a bigger problem. I've tried to patch the gtkreactor but I failed, I'm considering switching mainly because the twisted developers won't fix it in a relatively small time, and also because it's the second time that I've rewritten the app in twisted to workaround this problem. (first time: perspective broker, second time: consumer/producer), I was really unlucky! – pygabriel Jun 07 '10 at 19:32
  • 1
    http://twistedmatrix.com/trac/changeset/29244/branches/gtk2-io-deprioritize-4489 shows the gtk2reactor fix necessary. Fortunately it turned out to be quite a simple change. – Jean-Paul Calderone Jun 07 '10 at 21:41
  • @Jean-Paul thank you for pointing me this, in this way I can deliver my app instantly! – pygabriel Jun 07 '10 at 22:07

4 Answers4

1

Two threads: one for the GUI, one for sending/receiving data. Tkinter would be a perfectly fine toolkit for this. You don't need twisted or any other external libraries or toolkits -- what comes out of the box is sufficient to get the job done.

Bryan Oakley
  • 370,779
  • 53
  • 539
  • 685
1

Disclaimer: I have little experience with network applications.

That being said, the raw sockets isn't terribly difficult to wrap your head around/use, especially if you're not too worried about optimization. That takes more thought, of course. But using GTK and raw sockets should be fairly straightforward. Especially since you've used the twisted framework, which IIRC, just abstracts some of the more nitty-gritty details of socket managing.

Wayne Werner
  • 49,299
  • 29
  • 200
  • 290
1

If your application is somewhat similar to bittorrent, why not check the source code of Deluge http://deluge-torrent.org/ and build from it? It is written in Python, it does use the bittorrent protocol and it does have a GTK user interface.

mawimawi
  • 4,222
  • 3
  • 33
  • 52
1

As an alternative to twisted and whatever GUI library you seem to be using, how about trying PyQt? It provides a GUI and non-blocking sockets all in the same event loop. That way you don't have to worry about interoperability issues, which seem to be the issue you are facing.

Hope this helps!

blwy10
  • 4,862
  • 2
  • 24
  • 23