This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import logging | |
| logger_format = '%(asctime)s:%(threadName)s:%(message)s' | |
| logging.basicConfig(format=logger_format, level=logging.INFO, datefmt="%H:%M:%S") | |
| num_word_mapping = {1: 'ONE', 2: 'TWO', 3: "THREE", 4: "FOUR", 5: "FIVE", 6: "SIX", 7: "SEVEN", 8: "EIGHT", | |
| 9: "NINE", 10: "TEN"} | |
| def delay_message(delay, message): | |
| logging.info(f"{message} received") | |
| time.sleep(delay) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def delay_message(delay, message): | |
| logging.info(f"{message} received") | |
| time.sleep(delay) | |
| logging.info(f"Printing {message}") | |
| def main(): | |
| logging.info("Main started") | |
| threads = [threading.Thread(target=delay_message, args=(delay, message)) for delay, message in zip([2, 3], | |
| [num_word_mapping[2], num_word_mapping[3]])] | |
| for thread in threads: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import asyncio | |
| import logging | |
| import time | |
| logger_format = '%(asctime)s:%(threadName)s:%(message)s' | |
| logging.basicConfig(format=logger_format, level=logging.INFO, datefmt="%H:%M:%S") | |
| num_word_mapping = {1: 'ONE', 2: 'TWO', 3: "THREE", 4: "FOUR", 5: "FIVE", 6: "SIX", 7: "SEVEN", 8: "EIGHT", | |
| 9: "NINE", 10: "TEN"} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import asyncio | |
| import logging | |
| import time | |
| logger_format = '%(asctime)s:%(threadName)s:%(message)s' | |
| logging.basicConfig(format=logger_format, level=logging.INFO, datefmt="%H:%M:%S") | |
| num_word_mapping = {1: 'ONE', 2: 'TWO', 3: "THREE", 4: "FOUR", 5: "FIVE", 6: "SIX", 7: "SEVEN", 8: "EIGHT", | |
| 9: "NINE", 10: "TEN"} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import concurrent.futures as cf | |
| import logging | |
| import time | |
| logger_format = '%(asctime)s:%(threadName)s:%(message)s' | |
| logging.basicConfig(format=logger_format, level=logging.INFO, datefmt="%H:%M:%S") | |
| num_word_mapping = {1: 'ONE', 2: 'TWO', 3: "THREE", 4: "FOUR", 5: "FIVE", 6: "SIX", 7: "SEVEN", 8: "EIGHT", | |
| 9: "NINE", 10: "TEN"} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import asyncio | |
| import logging | |
| import time | |
| logger_format = '%(asctime)s:%(threadName)s:%(message)s' | |
| logging.basicConfig(format=logger_format, level=logging.INFO, datefmt="%H:%M:%S") | |
| num_word_mapping = {1: 'ONE', 2: 'TWO', 3: "THREE", 4: "FOUR", 5: "FIVE", 6: "SIX", 7: "SEVEN", 8: "EIGHT", | |
| 9: "NINE", 10: "TEN"} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import concurrent.futures as cf | |
| import logging | |
| import time | |
| logger_format = '%(asctime)s:%(threadName)s:%(message)s' | |
| logging.basicConfig(format=logger_format, level=logging.INFO, datefmt="%H:%M:%S") | |
| class DbUpdate: | |
| def __init__(self): | |
| self.value = 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import asyncio | |
| import logging | |
| import time | |
| logger_format = '%(asctime)s:%(threadName)s:%(message)s' | |
| logging.basicConfig(format=logger_format, level=logging.INFO, datefmt="%H:%M:%S") | |
| class DbUpdate: | |
| def __init__(self): | |
| self.value = 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import asyncio | |
| async def foo(): | |
| await boo() | |
| async def boo(): | |
| await foo() | |
| async def main(): | |
| await asyncio.gather(*[foo(), boo()]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import concurrent.futures as cf | |
| import logging | |
| import time | |
| import threading | |
| LOCK = threading.Lock() | |
| logger_format = '%(asctime)s:%(threadName)s:%(message)s' | |
| logging.basicConfig(format=logger_format, level=logging.INFO, datefmt="%H:%M:%S") |
OlderNewer