Opened 2 years ago

Last modified 2 years ago

#3507 new bug

AddTorrentError not handled in RPCserver

Reported by: DjLegolas Owned by:
Priority: minor Milestone: needs verified
Component: Core Version: develop
Keywords: Cc:

Description

While checking #3320, I noticed that when adding the same torrent file as one of ones in the session, I get the next error, instead on the AddTorrentError exception.
I'm working on the latest develop branch to this time, in thin client mode.
This error is also being forwarded to the client (as expected).

20:03:48.549 [INFO    ][deluge.core.torrent           :64  ] Adding any new trackers to torrent (7a95c54468a18811d641325d494f7ec7760e0e01) already in session...
20:03:48.550 [WARNING ][deluge.core.core              :67  ] Error when adding torrent: Torrent already in session (7a95c54468a18811d641325d494f7ec7760e0e01).
20:03:48.550 [WARNING ][deluge.core.rpcserver         :67  ] Error occurred when sending message: type <class 'deluge.error.AddTorrentError'> not handled.
20:03:48.550 [ERROR   ][deluge.core.rpcserver         :72  ] type <class 'deluge.error.AddTorrentError'> not handled
Traceback (most recent call last):
  File "C:\develops\python\deluge\deluge\core\rpcserver.py", line 155, in sendData
    self.transfer_message(data)
  File "C:\develops\python\deluge\deluge\transfer.py", line 53, in transfer_message
    body = zlib.compress(rencode.dumps(data))
  File "rencode/rencode.pyx", line 336, in rencode._rencode.dumps
  File "rencode/rencode.pyx", line 316, in rencode._rencode.encode
  File "rencode/rencode.pyx", line 249, in rencode._rencode.encode_list
  File "rencode/rencode.pyx", line 316, in rencode._rencode.encode
  File "rencode/rencode.pyx", line 249, in rencode._rencode.encode_list
  File "rencode/rencode.pyx", line 322, in rencode._rencode.encode
Exception: type <class 'deluge.error.AddTorrentError'> not handled
20:03:48.551 [WARNING ][deluge.core.rpcserver         :67  ] An exception occurred while sending RPC_ERROR to client. Wrapping it and resending. Error to send(causing exception goes next):
Traceback (most recent call last):
  File "C:\develops\python\deluge\deluge\core\rpcserver.py", line 335, in on_success
    self.sendData((RPC_RESPONSE, request_id, result))
  File "C:\develops\python\deluge\deluge\core\rpcserver.py", line 155, in sendData
    self.transfer_message(data)
  File "C:\develops\python\deluge\deluge\transfer.py", line 53, in transfer_message
    body = zlib.compress(rencode.dumps(data))
  File "rencode/rencode.pyx", line 336, in rencode._rencode.dumps
  File "rencode/rencode.pyx", line 316, in rencode._rencode.encode
  File "rencode/rencode.pyx", line 249, in rencode._rencode.encode_list
  File "rencode/rencode.pyx", line 316, in rencode._rencode.encode
  File "rencode/rencode.pyx", line 249, in rencode._rencode.encode_list
  File "rencode/rencode.pyx", line 322, in rencode._rencode.encode
Exception: type <class 'deluge.error.AddTorrentError'> not handled

Change History (2)

comment:1 Changed 2 years ago by gazpachoking

Looked in to this a bit, this seems like the problem: The 'core.add_torrent_files' method never fails, it returns a list, which contains an Exception for each attempted torrent add, (if any Exceptions occurred.) When transmitting a success result over RPC, only basic data types that rencode can handle are able to be sent, so a list of Exceptions causes the above issue.

Not really sure what the best answer for this is.

  • We could make the exception rebuilding like we do in the failure callback work for any Exceptions being sent.
  • We could just raise the error, but that's not a great answer, because some torrents were possibly added successfully, and there might be more than one error for torrents that weren't added successfully.

comment:2 Changed 2 years ago by DjLegolas

In addition, the whole purpose of #3320 is to stop printing the traceback when AddTorrentError was raised...
Or even, not raise an exception at all.

Note: See TracTickets for help on using tickets.