Add a scheduler

This commit is contained in:
Jake Howard 2019-02-14 19:37:17 +00:00
parent 58b478c937
commit 378ac11656
Signed by: jake
GPG key ID: 57AFB45680EDD477
4 changed files with 99 additions and 33 deletions

View file

@ -21,3 +21,4 @@ allow_prereleases = true
[packages] [packages]
aiohttp = "*" aiohttp = "*"
apscheduler = "*"

108
Pipfile.lock generated
View file

@ -1,7 +1,7 @@
{ {
"_meta": { "_meta": {
"hash": { "hash": {
"sha256": "0f025f2c0a2195605a3e25cef24d83f6c34c4a197230efdfef49d2716dd36caa" "sha256": "51ea2d5cdebbe8681e35959921839ceecbd37164697962c5fa7b6d815982bd83"
}, },
"pipfile-spec": 6, "pipfile-spec": 6,
"requires": { "requires": {
@ -18,27 +18,46 @@
"default": { "default": {
"aiohttp": { "aiohttp": {
"hashes": [ "hashes": [
"sha256:0c5a7b270b7d1437eb21ad11dbd97365ec063ffca9beba3a519067f686f7a0a8", "sha256:02396865118790ebb0bd14d6935e9e4fa80d87683240618894e585048a8b83ec",
"sha256:0d4cadba74fed3ef448d34f9ea285ea862ff36ff59b68c18b21ecdcdf0a63397", "sha256:0f448b5d5cd45e642b9fcf4798e48cca4149ae479022f59bd67a47caed44657e",
"sha256:0ee048a1b452dba7f0547765501de1f5db80c9494c46c009e6138ef11755bd6a", "sha256:1af72f53ccead6d161296e576aa2b5d0c6c7403a389601dd7aa7a7a30a9f41c3",
"sha256:120f32516db19cc2e30920c54cb769f27b000390f74831f154573776677a41e8", "sha256:32eeef64a5bcf6dc652f19e020b16f36ec66d291957f62ffad18ecfc58695966",
"sha256:21d8de1451fbff4f84780566012026707073fcf15f646b7aab33a56ae27392f9", "sha256:36c4e234a85a81e325d8b1d7fdeb696a3d51bb8eb09a8c8e69c7532b421e8a29",
"sha256:450029dc3d3134152a17ea56926e1adb1ef29b6ad8f9dbfb75f7c6c1d6311e9f", "sha256:371a5f1bb604fc262ba32893931f5aad3bb3e797dbebcf2b5b2c36f97603e4c7",
"sha256:4eff34add9668875afb43f69df04364f5aac661abe485e60010e9beebb6f4784", "sha256:3f5a30f67e4152d4075063ae9f2286313af2e39b950869edba76232569e08793",
"sha256:84aa603a85f928d7aa7f02ad0e2c1fe0c8d95816e54c6f6549fad75027a6001b", "sha256:48c65d65d0de79f1a4391bc29c8c8ec7655671a03ad7902d5e66fd735531893e",
"sha256:b5a1b78d9a419c819e2d8a3750db1f25e470a062a2fb6d315df0163f775a7381", "sha256:4ede22808195126d55879f1a14aaa3d1004f188c341f92ec3b9ca5ea13e695b9",
"sha256:d091799fcf01420049db1584d9d586c48f2d50a830ed384a3cce2bd11936b310", "sha256:53228028648b40f59fc941c0cd67b7899bce52f35eb66aeb9e33b75bac0aac0a",
"sha256:ec420a3143a6dad8dd383510b6d47ef96910574e2795c866e9225841cd4585d5" "sha256:67cb8e71c043686f806cfdb4189774c57ef929d32890024c3775d72b54381797",
"sha256:6b1e99dc838c28f14e45bffef6fb77bf5b54bd2bfb1a475c776da5ba8a9fec2d",
"sha256:6c30eca95e7d60fbf13e6ebcaf62b7c0f3f93ec5de8862919aa5ede3720b1c86",
"sha256:6f2c905ab82aa0ee8a06210d5a6c1359c79f3f2088cc1b53c8758cae1dbc0d55",
"sha256:746b73eff86a1618025093b9c86ff4d642cff71a7ac7244f7fd8a186967cee22",
"sha256:9ebf518c7bc08e65b5396f80e8155c7bb1380b921b84b510570e62196c9fca56",
"sha256:9efc80ced0936f3fb2774e1bc981006324c74d1e58fc7f7164ecd98ede727c7d",
"sha256:abc43651f2c6d70b812cb874fc8caa00eb69fac11930cd2640d32a11ee7beef0",
"sha256:b4c6e1f5a591511537d4ccd4c807f6c8bb8d1b8a5043395950ba339086380904",
"sha256:bee80820a8ef5f6bddd58d762fc9f981ef1041a464d382d7d9a992bb94cd23c6",
"sha256:f0c304dcc1494dbc3fc492ebc2e61d0db323be9756a1bb14f407097d8adf82ec",
"sha256:fb9c2f27d2db6d709a02421733bb6ad22e16104beb2cf403e1120c24f3cc8668"
], ],
"index": "pypi", "index": "pypi",
"version": "==3.0.0b0" "version": "==4.0.0a0"
},
"apscheduler": {
"hashes": [
"sha256:6599bc78901ee7e9be85cbd073d9cc155c42d2bc867c5cde4d4d1cc339ebfbeb",
"sha256:a8fe0c82d1c21bcf4a1b0e00aa35709f1f63fdd36446e406fa56cc0d51d3acc6"
],
"index": "pypi",
"version": "==3.5.3"
}, },
"async-timeout": { "async-timeout": {
"hashes": [ "hashes": [
"sha256:00cff4d2dce744607335cba84e9929c3165632da2d27970dbc55802a0c7873d0", "sha256:0c3c816a028d47f659d6ff5c745cb2acf1f966da1fe5c19c77a70282b25f4c5f",
"sha256:9093db5b8ddbe4b8f6885d1a6e0ad84ae3155464cbf6877c387605244c285f3c" "sha256:4291ca197d287d274d0b6cb5d6f8f8f82d434ed288f962539ff18cc9012f9ea3"
], ],
"version": "==2.0.1" "version": "==3.0.1"
}, },
"attrs": { "attrs": {
"hashes": [ "hashes": [
@ -65,6 +84,7 @@
"hashes": [ "hashes": [
"sha256:a933e3bb13da54383f9e8f35dc4f9cb9eb9b3b78c6b36f311254d6d0d92c6c7c" "sha256:a933e3bb13da54383f9e8f35dc4f9cb9eb9b3b78c6b36f311254d6d0d92c6c7c"
], ],
"markers": "python_version < '3.7'",
"version": "==1.1.0" "version": "==1.1.0"
}, },
"multidict": { "multidict": {
@ -101,23 +121,51 @@
], ],
"version": "==4.5.2" "version": "==4.5.2"
}, },
"pytz": {
"hashes": [
"sha256:32b0891edff07e28efe91284ed9c31e123d84bea3fd98e1f72be2508f43ef8d9",
"sha256:d5f05e487007e29e03409f9398d074e158d920d36eb82eaf66fb1136b0c5374c"
],
"version": "==2018.9"
},
"six": {
"hashes": [
"sha256:3350809f0555b11f552448330d0b52d5f24c91a322ea4a15ef22629740f3761c",
"sha256:d16a0141ec1a18405cd4ce8b4613101da75da0e9a7aec5bdd4fa804d0e0eba73"
],
"version": "==1.12.0"
},
"typing-extensions": {
"hashes": [
"sha256:07b2c978670896022a43c4b915df8958bec4a6b84add7f2c87b2b728bda3ba64",
"sha256:f3f0e67e1d42de47b5c67c32c9b26641642e9170fe7e292991793705cd5fef7c",
"sha256:fb2cd053238d33a8ec939190f30cfd736c00653a85a2919415cecf7dc3d9da71"
],
"markers": "python_version < '3.7'",
"version": "==3.7.2"
},
"tzlocal": {
"hashes": [
"sha256:27d58a0958dc884d208cdaf45ef5892bf2a57d21d9611f2ac45e51f1973e8cab",
"sha256:f124f198e5d86b3538b140883472beaa82d2c0efc0cd9694dfdbe39079e22e69"
],
"version": "==2.0.0b1"
},
"yarl": { "yarl": {
"hashes": [ "hashes": [
"sha256:3278209d78d534d59ee44f595e54ee4d3a164fa77319ffbd418b1978edf71748", "sha256:024ecdc12bc02b321bc66b41327f930d1c2c543fa9a561b39861da9388ba7aa9",
"sha256:32a52453fc20153e34d2cf99f1a2f4c3d144e320896f1f89b5ee89bb41e877be", "sha256:2f3010703295fbe1aec51023740871e64bb9664c789cba5a6bdf404e93f7568f",
"sha256:48f3807855b69414a41e70908e502d6dbf563e3eca22f73d1344aad9270a4ff9", "sha256:3890ab952d508523ef4881457c4099056546593fa05e93da84c7250516e632eb",
"sha256:4c2d780cb0b669bf027da57a0834d4968ed55c89f1593cfd11be8108bff699e2", "sha256:3e2724eb9af5dc41648e5bb304fcf4891adc33258c6e14e2a7414ea32541e320",
"sha256:843c90c7a2756c033e9bb4464f789e21bc33f561c1e6c0ef7569f452b33a761a", "sha256:5badb97dd0abf26623a9982cd448ff12cb39b8e4c94032ccdedf22ce01a64842",
"sha256:8765ebd034d0dc812a311b31251dffb434c753fc7124487912a5bca7baeb5c9b", "sha256:73f447d11b530d860ca1e6b582f947688286ad16ca42256413083d13f260b7a0",
"sha256:a2dda88459cfe50f4f6a225d2f51e3fffb0c3c18f4c3a3ac38d9dc054f8c37b0", "sha256:7ab825726f2940c16d92aaec7d204cfc34ac26c0040da727cf8ba87255a33829",
"sha256:ac574aa2c45185e038489ff8f3bebd9269dd8327e86c72d9a7f83a1d3ad9eec4", "sha256:b25de84a8c20540531526dfbb0e2d2b648c13fd5dd126728c496d7c3fea33310",
"sha256:ce5963f2451661a435721d8907a824daea52aad6e3bee9b4104e75d19269cdae", "sha256:c6e341f5a6562af74ba55205dbd56d248daf1b5748ec48a0200ba227bb9e33f4",
"sha256:ceae77215870ecaba555b2e74dd308de9abe6d44b0eecafae6ecef4a14e289f8", "sha256:c9bb7c249c4432cd47e75af3864bc02d26c9594f49c82e2a28624417f0ae63b8",
"sha256:cec06d4272c2ced65308daf63360daeea5061c030fe28f75e499afd735cee860", "sha256:e060906c0c585565c718d1c3841747b61c5439af2211e185f6739a9412dfbde1"
"sha256:ee506bc321b455b4a410724ec9c0ad4940932553523c6e7b69f0155269793734",
"sha256:fbbb10276d53629c0300cfd4a2092e3bbfa9a5aa95cd49808e01c59492052077"
], ],
"version": "==1.2.0" "version": "==1.3.0"
} }
}, },
"develop": { "develop": {

View file

@ -2,13 +2,18 @@ from multiprocessing import Process
from aiohttp.web import run_app as run_web_app from aiohttp.web import run_app as run_web_app
from actioner.scheduler import create_scheduler, start_scheduler
from actioner.web import get_server from actioner.web import get_server
import logging
def main(): def main():
logging.basicConfig(level=logging.INFO)
server = get_server() server = get_server()
web_process = Process(target=run_web_app, args=(server,)) scheduler = create_scheduler()
web_process.start()
Process(target=run_web_app, args=(server,)).start()
Process(target=start_scheduler, args=(scheduler,)).start()
if __name__ == '__main__': if __name__ == '__main__':

View file

@ -0,0 +1,12 @@
from apscheduler.schedulers.blocking import BlockingScheduler
import asyncio
def create_scheduler():
scheduler = BlockingScheduler()
return scheduler
def start_scheduler(scheduler):
scheduler.start()
asyncio.get_event_loop().run_forever()