April 2024 - This site, and Kamaelia are being updated. There is significant work needed, and PRs are welcome.


BitTorrent Sharing Service

The TorrentService component provides a service that allows the sharing of a single BitTorrent Client with more than one component that might want to use it.

Use the TorrentPatron component to make use of BitTorrent through this service.

Generally, you should not create a TorrentService yourself. If one is needed, one will be created by TorrentPatron. If a TorrentService already exists, creating one yourself may crash Python (see the effects of creating two TorrentClient components in TorrentClient.py)

The shutting down of this component (when it is no longer in use) is very ugly.

How does it work?

This component forwards messages from TorrentPatrons to a single TorrentClient it creates and also delivers responses from TorrentClient to the TorrentPatron appropriate to the response content.

TorrentClient handles new torrent requests sequentially, so as long as we keep a record of what order the requests of TorrentPatrons were forwarded, we can work out who to send TorrentClient's response to. Then, since all further messages are assigned a torrentid by TorrentClient, we can route all messages labelled with a particular id to to the TorrentPatron that started that torrent.


class TorrentService(Axon.AdaptiveCommsComponent.AdaptiveCommsComponent)

TorrentService() -> new TorrentService component

Use TorrentService.getTorrentService(...) in preference as it returns an existing instance, or automatically creates a new one.


  • control : Recieving a Axon.Ipc.shutdown() message here causes shutdown
  • _torrentcontrol : Notice that TorrentClient has shutdown
  • inbox : Connects to TorrentClient (the BitTorrent code)
  • notify : Used to be notified about things to select


  • debug : Information that may aid debugging
  • outbox : Connects to TorrentClient (the BitTorrent code)
  • signal : Not used

Methods defined here


You should be using the inbox/outbox interface, not these methods (except construction). This documentation is designed as a roadmap as to their functionalilty for maintainers and new component developers.


addClient(self, replyService)

Registers a TorrentPatron with this service, creating an outbox connected to it

debug(self, msg)



Main loop

removeClient(self, replyService)

Deregisters a TorrentPatron with this service, deleting its outbox

sendToClient(self, msg, replyService)

Send a message to a TorrentPatron


Got a problem with the documentation? Something unclear that could be clearer? Want to help improve it? Constructive criticism is very welcome - especially if you can suggest a better rewording!

Please leave you feedback here in reply to the documentation thread in the Kamaelia blog.

-- Automatic documentation generator, 05 Jun 2009 at 03:01:38 UTC/GMT