From 91aa046ffdb7fded842cc66878368633500760cf Mon Sep 17 00:00:00 2001 From: Eduardo Chapa Date: Wed, 12 Jul 2023 20:11:16 -0600 Subject: [PATCH 1/2] Para evitar errores en macOS --- 4.-process.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/4.-process.py b/4.-process.py index 54ad1de..5255a7b 100644 --- a/4.-process.py +++ b/4.-process.py @@ -14,13 +14,15 @@ def fibonnaci(number): start = time.time() -a = Process(target=lambda: print(fibonnaci(41)) ) -b = Process(target=lambda: print(fibonnaci(42)) ) +if __name__ == '__main__': -a.start() -b.start() + a = Process(target=print(fibonnaci(30))) + b = Process(target=print(fibonnaci(31))) -a.join() -b.join() + a.start() + b.start() -print(time.time()- start) \ No newline at end of file + a.join() + b.join() + + print(time.time()- start) From 5fcfc37ace672eaaff10fd8a9207a8824d2c8f39 Mon Sep 17 00:00:00 2001 From: Eduardo Chapa Date: Wed, 12 Jul 2023 20:32:03 -0600 Subject: [PATCH 2/2] Para que funcione en macOS --- 3.-event.py | 2 +- main.py | 19 ++++++++++--------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/3.-event.py b/3.-event.py index 93a8ed2..550933c 100644 --- a/3.-event.py +++ b/3.-event.py @@ -27,7 +27,7 @@ def deposit(self): def withdraw(self): for _ in range(1_000_000): with lock: - self.balance += 1 + self.balance -= 1 def loading(event): diff --git a/main.py b/main.py index f5886d2..880303f 100644 --- a/main.py +++ b/main.py @@ -17,8 +17,8 @@ def is_prime(number): if number < 2: return False - # for x in range(2, int(number ** 0.5) + 1): - for x in range(2, number): + for x in range(2, int(number ** 0.5) + 1): + # for x in range(2, number): if number % x == 0: return False @@ -30,13 +30,14 @@ def is_prime(number): tasks = [] numbers = [174440041, 3657500101, 88362852307, 414507281407, 2428095424619, 4952019383323, 12055296811267, 17461204521323, 28871271685163, 53982894593057] -for number in numbers: - thread = Process(target=lambda: print(is_prime(number))) - thread.start() - tasks.append(thread) +if __name__ == '__main__': + for number in numbers: + thread = Process(target=print(is_prime(number))) + thread.start() + tasks.append(thread) -for task in tasks: - task.join() + for task in tasks: + task.join() -print(time.time()- start) \ No newline at end of file + print(time.time()- start)