pdb> pp __exception__
(
ClientError...)
This blog is for technical and personal posts. Over different jobs over the years I've written hundreds of articles, and now it's time to share with everyone!
![]() |
#!/usr/bin/env python ''' mptest_proxy.py -- producer adds to fixed-sized list; scanner uses them OPTIONS: -v verbose multiprocessing output ''' import logging, multiprocessing, sys, time def producer(objlist): ''' add an item to list every 2 sec; ensure fixed size list ''' logger = multiprocessing.get_logger() logger.info('start') while True: try: time.sleep(1) except KeyboardInterrupt: return msg = 'ding: {:04d}'.format(int(time.time()) % 10000) logger.info('put: %s', msg) del objlist[0] objlist.append( msg ) def scanner(objlist): ''' every now and then, run calculation on objlist ''' logger = multiprocessing.get_logger() logger.info('start') while True: try: time.sleep(5) except KeyboardInterrupt: return logger.info('items: %s', list(objlist)) def main(): opt_verbose = '-v' in sys.argv[1:] logger = multiprocessing.log_to_stderr( level=logging.DEBUG if opt_verbose else logging.INFO, ) logger.info('setup') # create fixed-length list, shared between producer & consumer manager = multiprocessing.Manager() my_objlist = manager.list( # pylint: disable=E1101 [None] * 10 ) multiprocessing.Process( target=producer, args=(my_objlist,), name='producer', ).start() multiprocessing.Process( target=scanner, args=(my_objlist,), name='scanner', ).start() logger.info('running forever') try: manager.join() # wait until both workers die except KeyboardInterrupt: pass logger.info('done') if __name__=='__main__': main()
sudo apt-get install python-pyside
sudo pip install Ghost.py
python -c 'from ghost import Ghost'
#!/usr/bin/python
from ghost import Ghost
ghost = Ghost()
ghost.open('http://duckduckgo.com/')
ghost.wait_for_selector('input[name=q]')
ghost.fill("#search_form_homepage", {'q': 'beer'})
ghost.fire_on("#search_form_homepage",
"submit",
expect_loading=True)
ghost.wait_for_selector('#r1-0')
result, _resources = ghost.evaluate(
"document.getElementById('r1-0').innerHTML;")
print result
ghost.capture_to('beer.png')
Here are the slides and notes for "Functional Programming and Django QuerySets" (2016 edition) -- have fun! http://johntellsall.github.io/johntellsall.com/class/django-queryset3/_build/