twisted

How to use APscheduler with scrapy

徘徊边缘 提交于 2020-08-24 16:19:05
问题 have this code who run scrapy crawler from script(http://doc.scrapy.org/en/latest/topics/practices.html#run-scrapy-from-a-script). But it doesn't work. from twisted.internet import reactor from scrapy.crawler import Crawler from scrapy import log,signals from spiders.egov import EgovSpider from scrapy.utils.project import get_project_settings def run(): spider =EgovSpider() settings = get_project_settings() crawler = Crawler(settings) crawler.signals.connect(reactor.stop, signal=signals

Scrapy raises ReactorNotRestartable when CrawlerProcess is ran twice

喜你入骨 提交于 2020-08-03 05:58:45
问题 I have some code which looks something like this: def run(spider_name, settings): runner = CrawlerProcess(settings) runner.crawl(spider_name) runner.start() return True I have two py.test tests which each call run(), when the second test executes I get the following error. runner.start() ../../.virtualenvs/scrape-service/lib/python3.6/site-packages/scrapy/crawler.py:291: in start reactor.run(installSignalHandlers=False) # blocking call ../../.virtualenvs/scrape-service/lib/python3.6/site

Scrapy raises ReactorNotRestartable when CrawlerProcess is ran twice

痞子三分冷 提交于 2020-08-03 05:58:12
问题 I have some code which looks something like this: def run(spider_name, settings): runner = CrawlerProcess(settings) runner.crawl(spider_name) runner.start() return True I have two py.test tests which each call run(), when the second test executes I get the following error. runner.start() ../../.virtualenvs/scrape-service/lib/python3.6/site-packages/scrapy/crawler.py:291: in start reactor.run(installSignalHandlers=False) # blocking call ../../.virtualenvs/scrape-service/lib/python3.6/site

Celery worker hang when running with twisted

蓝咒 提交于 2020-06-25 07:11:57
问题 Below code snippet is the celery setup I have, Here I am running a twisted reactor in each child celery worker process. import os from threading import Thread from celery import Celery from twisted.internet import threads, reactor from celery import signals from twisted.internet.defer import inlineCallbacks, returnValue from twisted.internet.task import LoopingCall app = Celery('tasks', broker='pyamqp://guest@localhost//') @signals.worker_process_init.connect def configure_infrastructure(*

python websocket failure when run in openshift

孤人 提交于 2020-06-17 03:05:32
问题 I have a autobahn twisted websocket running in python which is working in a dev vm correctly but I have been unable to get working when the server is running in openshift. Here is the shortened code which works for me in a vm. from autobahn.twisted.websocket import WebSocketServerProtocol, WebSocketServerFactory, listenWS from autobahn.twisted.resource import WebSocketResource class MyServerProtocol(WebSocketServerProtocol): def onConnect(self, request): stuff... def onOpen(self): stuff...

python websocket failure when run in openshift

偶尔善良 提交于 2020-06-17 03:05:17
问题 I have a autobahn twisted websocket running in python which is working in a dev vm correctly but I have been unable to get working when the server is running in openshift. Here is the shortened code which works for me in a vm. from autobahn.twisted.websocket import WebSocketServerProtocol, WebSocketServerFactory, listenWS from autobahn.twisted.resource import WebSocketResource class MyServerProtocol(WebSocketServerProtocol): def onConnect(self, request): stuff... def onOpen(self): stuff...

OverflowError: Unsupported UTF-8 sequence length when > encoding string

你离开我真会死。 提交于 2020-06-08 05:25:39
问题 Inside a Twisted Resource, I am returning a json encoded dict as the response var below. The data is a list of 5 people with name, guid, and a couple other fields less than 32 characters long each, so not a ton of data. I get this OverflowError exception pretty often, but I don't quite understand what the unsupported utf-8 sequence length refers to. self.request.write(ujson.dumps(response)) exceptions.OverflowError: Unsupported UTF-8 sequence length when encoding string 回答1: When in doubt,

Django - Render a List of File Names to Template

左心房为你撑大大i 提交于 2020-05-17 04:36:06
问题 I am generating a template for an image gallery page. My approach is as follows: Host the images from a sub directory of an images folder The image folder will be titled the same as the gallery title The view passes a list of filenames to the template The template loops through the list and creates img tags So my view would be def some_gallery(request): #LOGIC TO GET A LIST OF FILENAMES variables = RequestContext(request,{ 'user' : request.user, 'title' : 'something', 'files' : fileList })

Django - Render a List of File Names to Template

谁都会走 提交于 2020-05-17 04:33:29
问题 I am generating a template for an image gallery page. My approach is as follows: Host the images from a sub directory of an images folder The image folder will be titled the same as the gallery title The view passes a list of filenames to the template The template loops through the list and creates img tags So my view would be def some_gallery(request): #LOGIC TO GET A LIST OF FILENAMES variables = RequestContext(request,{ 'user' : request.user, 'title' : 'something', 'files' : fileList })

twisted Int16StringReceiver little endian byte order

雨燕双飞 提交于 2020-04-30 07:42:08
问题 I'm trying to use this class provided by twisted to frame my tcp stream. But the default format they have is in big endian byte order but I need to read in little endian. So I did: class Player(basic.Int16StringReceiver): structFormat = "<H" def stringReceived(self, packet): print ':'.join(x.encode('hex') for x in packet) But for some reason stringReceived seldom gets called. Both client and server is on the same machine and I am very sure the client did send the data. So why is