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 urllib2 | |
| import os | |
| import sys | |
| import time | |
| import threading | |
| urls = ["http://broadcast.lds.org/churchmusic/MP3/1/2/nowords/271.mp3", | |
| "http://s1.fans.ge/mp3/201109/08/John_Legend_So_High_Remix(fans_ge).mp3", | |
| "http://megaboon.com/common/preview/track/786203.mp3"] |
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 threading | |
| import time | |
| import logging | |
| logging.basicConfig(level=logging.DEBUG, | |
| format='(%(threadName)-10s) %(message)s', | |
| ) | |
| def daemon(): | |
| logging.debug('Starting') |
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
| from PyQt4.QtCore import pyqtSignal, pyqtSlot | |
| from PyQt4.QtGui import QWidget, QApplication | |
| from PyQt4 import QtCore | |
| import sys | |
| _qObject = QtCore.QObject() | |
| class SomeOtherClass(QWidget): |
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
| from PyQt4.QtCore import pyqtSignal, pyqtSlot | |
| from PyQt4.QtGui import QWidget, QApplication | |
| import sys | |
| class SomeClass(QWidget): | |
| # Declare a new signal - passes Exception | |
| has_error = pyqtSignal(Exception) | |
| def __init__(self, parent=None): | |
| super(SomeClass, self).__init__(parent) |
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
| """ | |
| Find maximum memory consumed by a process specified at the command-line. | |
| Usage: | |
| $ python memory-usage-wait3.py cmd arg1 arg2 | |
| """ | |
| import os | |
| import sys | |
| import threading |
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 threading | |
| def f(arg): | |
| global running | |
| running += 1 | |
| print("Spawned a thread. running=%s, arg=%s" % (running, arg)) | |
| for i in range(100000): | |
| pass | |
| running -= 1 | |
| print("Done") |
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
| from multiprocessing import Pool | |
| def calculate(number): | |
| return number | |
| if __name__ == '__main__': | |
| pool = Pool() | |
| result = pool.map(calculate, range(4)) |
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
| from concurrent.futures import ProcessPoolExecutor | |
| def calculate(number): | |
| return number | |
| with ProcessPoolExecutor() as executor: | |
| result = executor.map(calculate, range(4)) |
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
| You can write the threaded example as: | |
| import concurrent.futures | |
| import itertools | |
| import random | |
| def generate_random(count): | |
| return [random.random() for _ in range(count)] | |
| if __name__ == "__main__": | |
| with concurrent.futures.ThreadPoolExecutor(max_workers=2) as executor: |
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
| set cut_paste_input [stack 0] | |
| version 8.0 v6 | |
| push $cut_paste_input | |
| NoOp { | |
| name NoOp2 | |
| selected true | |
| xpos 824 | |
| ypos -172 | |
| addUserKnob {20 User} | |
| addUserKnob {12 pixelCoordinate} |