Posts

Showing posts from July, 2023

Python: Multiprocessing Vs. Multithreading

 <put a cool image here> Multi Threading is GOOD when: It is perfect for I/O operations such as web scraping, because the processor is sitting idle waiting for data. MultiThreading is BAD when: For CPU intensive processes, there is little benefit to using the threading module. Mulitprocessing   Multiprocessing allows you to create programs that can run concurrently (bypassing the GIL) and use the entirety of your CPU core.  Since the processes don’t share memory, they can’t modify the same memory concurrently.    The entire memory is copied into each subprocess, which can be a lot of overhead for more significant programs   When to use each: If your code has a lot of I/O or Network usage , multithreading is your best bet because of its low overhead. If you have a GUI , use multithreading so your UI thread doesn’t get locked up. If your code is CPU bound , you should use multiprocessing (if your machine has multiple cores

Using OneDrive (Linux/SharePoint Client)

Home page: https://abraunegg.github.io/ GitHub: https://github.com/abraunegg/onedrive/blob/master/README.md How-To Document: https://github.com/abraunegg/onedrive/blob/master/docs/USAGE.md Upload only: onedrive --synchronize --upload-only --no-remote-delete <--dry-run>

Mounting a Network Storage Drive

 sudo mount.cifs //rssmbprd.carleton.ca/BaChu$ /home/nickshiell/storage -o vers=3,username=nickshiell,domain=cunet,uid=$(id -u),gid=$(id -g)

Shortern Terminal Prompt

 PS1='\u:\W\$ '

Fixing ModuleNotFoundError

Image
Example 1:   While working on a project using many modules spread through out a complex folder structure (see figure 1). I got a  "ModuleNotFoundError" error saying python couldn't locate the module "jsonschema".  VSCode had highlighted it in yellow.  Checking that the page is installed in the activate conda environment: I check the "Python Interpret" being used by VSCode using the command plate (crtl-shft-p): By Default the "recommended" interpreter was slected.  I changed the value to the option labeled 'conda' SUCCESS! Example 2: While working on a project using many modules spread through out a complex folder structure (see figure 1). I got a  "ModuleNotFoundError" error saying python couldn't locate the module "RedditUtils".  Put a '.' in front of the folder name 'RedditUtils' in the line "from RedditUtils import *".