Task | Strategy |
---|---|
Enable defaultIsolation(MainActor.self) (or similar) |
Try in a small module first, see how many warnings drop or relevant behaviour changes. |
Use @concurrent for functions that can truly run off the actor |
Be careful: concurrency changes may expose data races if shared mutable state isn’t protected. |
Replace uses of unsafe pointers or buffer manipulation with Span / safer APIs where possible |
Especially in embedded / systems code. |
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 main(filename): | |
try: | |
file = open(filename,"r") # Open the file with read mode | |
images_url = file.readlines() | |
for i in images_url: | |
downloader(i) # Downloading ... | |
file.close() | |
return True # Successfully downloaded | |
except IOError: | |
return False # File does not exists |
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 downloader(image_url): | |
# Generate random numbers from 1 to 10000 | |
randnumber = random.randrange(1,10000) | |
# Get the images extention | |
name, ext = get_image_ext(image_url) | |
# Full image name | |
images_name = str(randnumber) + ext |
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 get_image_ext(filepath): | |
''' | |
This function will check the file | |
extensions.If there is no file extensions, | |
then it will provide ".jpg" as default. | |
''' | |
base_name = os.path.basename(filepath) | |
name, ext = os.path.splitext(base_name) | |
if ext == "": | |
ext = ".jpg" |
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
#! /usr/bin/python3 | |
import os | |
import random | |
import urllib.request | |
def create_or_get_directory(dirName): | |
''' | |
I will create a directory to store |