C# first class continuation via C++ interop or some other way?

There is the C# 5 CTP, which performs a continuation-passing-style transformation over methods declared with the new async keyword, and continuation-passing based calls when using the await keyword. This is not actually a new CLR feature but rather a set of directives for the compiler to perform the CPS transformation over your code and a … Read more

celery – Tasks that need to run in priority

Celery does not support task priority. (v3.0) http://docs.celeryproject.org/en/master/faq.html#does-celery-support-task-priorities You may solve this problem by routing tasks. http://docs.celeryproject.org/en/latest/userguide/routing.html Prepare default and priority_high Queue. from kombu import Queue CELERY_DEFAULT_QUEUE = ‘default’ CELERY_QUEUES = ( Queue(‘default’), Queue(‘priority_high’), ) Run two daemon. user@x:/$ celery worker -Q priority_high user@y:/$ celery worker -Q default,priority_high And route task. your_task.apply_async(args=[‘…’], queue=”priority_high”)

How to obtain the results from a pool of threads in python?

In Python 3.x, you can use concurrent.futures.ThreadPoolExecutor to do this, rather than rolling your own. Python 2.x actually has a built-in thread pool you can use as well, its just not well documented: from multiprocessing.pool import ThreadPool def foo(word, number): print (word * number) r[(word,number)] = number return number words = [‘hello’, ‘world’, ‘test’, ‘word’, … Read more

Dumping a multiprocessing.Queue into a list

Try this: import Queue import time def dump_queue(queue): “”” Empties all pending items in a queue and returns them in a list. “”” result = [] for i in iter(queue.get, ‘STOP’): result.append(i) time.sleep(.1) return result import multiprocessing q = multiprocessing.Queue() for i in range(100): q.put([range(200) for j in range(100)]) q.put(‘STOP’) l=dump_queue(q) print len(l) Multiprocessing queues … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)