Skip to content
This repository has been archived by the owner on Jan 21, 2022. It is now read-only.

Implement garbage collector for sockets #38

Closed
ngosang opened this issue Apr 16, 2017 · 4 comments
Closed

Implement garbage collector for sockets #38

ngosang opened this issue Apr 16, 2017 · 4 comments
Labels

Comments

@ngosang
Copy link
Contributor

ngosang commented Apr 16, 2017

Peer should be destroyed after socket timeout or after several seconds without receiving data.
Now you are only destroying the peer if metadata is received
https://github.com/boramalper/magnetico/blob/master/magneticod/magneticod/__main__.py#L121
in other cases, number of peers (and sockets) increases forever until you reach OS limit and process crash.

@ad-m
Copy link
Contributor

ad-m commented Apr 18, 2017

@ngosang , please update issue title to respect content. Mention something like garbage collector for sockets.

@ngosang ngosang changed the title Bug report Implement garbage collector for sockets Apr 18, 2017
@ngosang
Copy link
Contributor Author

ngosang commented Apr 18, 2017

Done

@ad-m
Copy link
Contributor

ad-m commented Apr 18, 2017

I think there is a related stack trace:

Traceback (most recent call last):
  File "/home/artur/.local/lib/python3.5/site-packages/magneticod/bittorrent.py", line 77, in on_receivable
    received = self.__socket.recv(8192)
OSError: [Errno 9] Bad file descriptor

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "./magneticod", line 9, in <module>
    load_entry_point('magneticod==0.2.0', 'console_scripts', 'magneticod')()
  File "/home/artur/.local/lib/python3.5/site-packages/magneticod/__main__.py", line 81, in main
    loop()
  File "/home/artur/.local/lib/python3.5/site-packages/magneticod/__main__.py", line 154, in loop
    key.fileobj.on_receivable()
  File "/home/artur/.local/lib/python3.5/site-packages/magneticod/bittorrent.py", line 87, in on_receivable
    self.when_error()
  File "/home/artur/.local/lib/python3.5/site-packages/magneticod/__main__.py", line 131, in on_peer_error
    peers[info_hash].remove(peer)
ValueError: list.remove(x): x not in list

@boramalper
Copy link
Owner

@ad-m It's related to #3, not this one.

boramalper added a commit that referenced this issue Apr 25, 2017
magneticod:
* Stalled DisposablePeers are shut down after 120 seconds (fixes #47 and #38)
* Improved performance, thanks to @ngosang, @ad-m, and all other contributors (fixes #48)
* Default logging level is now set to INFO (since many users would freak out after seeing "peer failed" messages...)

magneticow:
* Search speed improved A LOT, like "A  L O T"! (fixes #8)
  (for the curious, the problem was that magneticow initialised database *every* *single* *time* a request is made because
  "the global application context" (`flask.g`) didn't work for some reason I don't know. Now it's blazing fast!
* A bit of logging added to assist the user. This is especially important as magneticow now takes a bit of time to initialize itself
  (as reasonably expected) and will not be able to handle any requests until it's complete.
* A faster but possibly less accurate (and not-guaranteed behaviour dependent) calculation of the number of torrents.
* Thousands separator for the torrent count in the homepage.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants