Skip to content

Commit

Permalink
Merge pull request #67 from therealdjryan/master
Browse files Browse the repository at this point in the history
Just tried this, and it works - thanks @therealdjryan!
  • Loading branch information
Ealdwulf committed Dec 16, 2015
2 parents 6a4df1f + f62dec0 commit c0528e3
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/common/aria2_downloader.py
Expand Up @@ -64,7 +64,9 @@ def start(self, blocking=False):
if self.hash_type:
checksum_opts = ['-V']
checksum_opt = '{}={}'.format(self.hash_type, self.hash_value)
port = 5900

port = self.find_available_port()

l1 = [
_aria2_path,
'-d', self.dest,
Expand Down Expand Up @@ -106,6 +108,15 @@ def start(self, blocking=False):
self.failed = True
self.failure = e

def find_available_port(self):
import socket
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind(("", 0))
s.listen(1)
port = s.getsockname()[1]
s.close()
return port

def getAriaStatus(self):
self.process.poll()
if not self.process.returncode:
Expand Down

0 comments on commit c0528e3

Please sign in to comment.