Skip to content

Commit

Permalink
Fixes #3148: Python 3.10 Deprecation Warnings (#3150)
Browse files Browse the repository at this point in the history
* refactored pid and time into variables for seed

* changed 1e10 on lines 287 & 331 to 10000000000 int
  • Loading branch information
alecgarza96 authored Mar 10, 2022
1 parent 56b2e4f commit 300b1ad
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 2 additions & 2 deletions luigi/target.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ def run(self):
with self.output().temporary_path() as self.temp_output_path:
run_some_external_command(output_path=self.temp_output_path)
"""
num = random.randrange(0, 1e10)
num = random.randrange(0, 10000000000)
slashless_path = self.path.rstrip('/').rstrip("\\")
_temp_path = '{}-luigi-tmp-{:010}{}'.format(
slashless_path,
Expand Down Expand Up @@ -328,7 +328,7 @@ def close(self):
self.move_to_final_destination()

def generate_tmp_path(self, path):
return os.path.join(tempfile.gettempdir(), 'luigi-s3-tmp-%09d' % random.randrange(0, 1e10))
return os.path.join(tempfile.gettempdir(), 'luigi-s3-tmp-%09d' % random.randrange(0, 10000000000))

def move_to_final_destination(self):
raise NotImplementedError()
Expand Down
4 changes: 3 additions & 1 deletion luigi/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,9 @@ def run(self):

if self.use_multiprocessing:
# Need to have different random seeds if running in separate processes
random.seed((os.getpid(), time.time()))
processID = os.getpid()
currentTime = time.time()
random.seed((processID, currentTime))

status = FAILED
expl = ''
Expand Down

0 comments on commit 300b1ad

Please sign in to comment.