axiom/batch.py
changed.
Showing 1 of 1 files from the diff.
@@ -5,15 +5,17 @@
Loading
5 | 5 | of data over an extended period of time. |
|
6 | 6 | """ |
|
7 | 7 | ||
8 | - | import weakref, datetime, os, sys |
|
8 | + | import weakref, datetime, sys |
|
9 | 9 | ||
10 | 10 | from zope.interface import implementer |
|
11 | 11 | ||
12 | 12 | from twisted.python import reflect, failure, log, procutils, util, runtime |
|
13 | 13 | from twisted.internet import task, defer, reactor, error, protocol |
|
14 | 14 | from twisted.application import service |
|
15 | + | from twisted.protocols.amp import AMP, Command, QuitBox, Path, Integer, String |
|
16 | + | from twisted.internet.task import cooperate |
|
15 | 17 | ||
16 | - | from epsilon import extime, process, cooperator, modal, juice |
|
18 | + | from epsilon import extime, modal |
|
17 | 19 | ||
18 | 20 | from axiom import iaxiom, errors as eaxiom, item, attributes |
|
19 | 21 | from axiom.scheduler import Scheduler, SubScheduler |
@@ -529,7 +531,7 @@
Loading
529 | 531 | ||
530 | 532 | ||
531 | 533 | ||
532 | - | class Shutdown(juice.Command): |
|
534 | + | class Shutdown(Command): |
|
533 | 535 | """ |
|
534 | 536 | Abandon, belay, cancel, cease, close, conclude, cut it out, desist, |
|
535 | 537 | determine, discontinue, drop it, end, finish, finish up, give over, go |
@@ -537,8 +539,8 @@
Loading
537 | 539 | off, leave off, miscarry, perorate, quit, refrain, relinquish, renounce, |
|
538 | 540 | resolve, scrap, scratch, scrub, stay, stop, terminate, wind up. |
|
539 | 541 | """ |
|
540 | - | commandName = "Shutdown" |
|
541 | - | responseType = juice.QuitBox |
|
542 | + | commandName = b"Shutdown" |
|
543 | + | responseType = QuitBox |
|
542 | 544 | ||
543 | 545 | ||
544 | 546 | def _childProcTerminated(self, err): |
@@ -659,9 +661,8 @@
Loading
659 | 661 | ||
660 | 662 | def _startProcess(self): |
|
661 | 663 | executable = sys.executable |
|
662 | - | env = os.environ |
|
663 | 664 | ||
664 | - | twistdBinaries = procutils.which("twistd2.4") + procutils.which("twistd") |
|
665 | + | twistdBinaries = procutils.which("twistd") |
|
665 | 666 | if not twistdBinaries: |
|
666 | 667 | return defer.fail(RuntimeError("Couldn't find twistd to start subprocess")) |
|
667 | 668 | twistd = twistdBinaries[0] |
@@ -685,8 +686,8 @@
Loading
685 | 686 | args = ['setsid'] + args |
|
686 | 687 | executable = setsid[0] |
|
687 | 688 | ||
688 | - | self.process = process.spawnProcess( |
|
689 | - | self.connector, executable, tuple(args), env=env) |
|
689 | + | self.process = reactor.spawnProcess( |
|
690 | + | self.connector, executable, tuple(args)) |
|
690 | 691 | ||
691 | 692 | class stopped(modal.mode): |
|
692 | 693 | def getProcess(self): |
@@ -741,7 +742,7 @@
Loading
741 | 742 | def stopProcess(self): |
|
742 | 743 | self.mode = 'stopping' |
|
743 | 744 | self.onShutdown = defer.Deferred() |
|
744 | - | Shutdown().do(self.juice) |
|
745 | + | self.juice.callRemote(Shutdown) |
|
745 | 746 | return self.onShutdown |
|
746 | 747 | ||
747 | 748 | def childProcessTerminated(self, reason): |
@@ -839,7 +840,7 @@
Loading
839 | 840 | ||
840 | 841 | ||
841 | 842 | ||
842 | - | class JuiceChild(juice.Juice): |
|
843 | + | class JuiceChild(AMP): |
|
843 | 844 | """ |
|
844 | 845 | Protocol class which runs in the child process |
|
845 | 846 |
@@ -849,57 +850,57 @@
Loading
849 | 850 | shutdown = False |
|
850 | 851 | ||
851 | 852 | def connectionLost(self, reason): |
|
852 | - | juice.Juice.connectionLost(self, reason) |
|
853 | + | AMP.connectionLost(self, reason) |
|
853 | 854 | if self.shutdown: |
|
854 | 855 | reactor.stop() |
|
855 | 856 | ||
857 | + | @Shutdown.responder |
|
856 | 858 | def command_SHUTDOWN(self): |
|
857 | 859 | log.msg("Shutdown message received, goodbye.") |
|
858 | 860 | self.shutdown = True |
|
859 | 861 | return {} |
|
860 | - | command_SHUTDOWN.command = Shutdown |
|
861 | 862 | ||
862 | 863 | ||
863 | 864 | ||
864 | - | class SetStore(juice.Command): |
|
865 | + | class SetStore(Command): |
|
865 | 866 | """ |
|
866 | 867 | Specify the location of the site store. |
|
867 | 868 | """ |
|
868 | - | commandName = 'Set-Store' |
|
869 | - | arguments = [('storepath', juice.Path())] |
|
869 | + | commandName = b'Set-Store' |
|
870 | + | arguments = [(b'storepath', Path())] |
|
870 | 871 | ||
871 | 872 | ||
872 | - | class SuspendProcessor(juice.Command): |
|
873 | + | class SuspendProcessor(Command): |
|
873 | 874 | """ |
|
874 | 875 | Prevent a particular reliable listener from receiving any notifications |
|
875 | 876 | until a L{ResumeProcessor} command is sent or the batch process is |
|
876 | 877 | restarted. |
|
877 | 878 | """ |
|
878 | - | commandName = 'Suspend-Processor' |
|
879 | - | arguments = [('storepath', juice.Path()), |
|
880 | - | ('storeid', juice.Integer())] |
|
879 | + | commandName = b'Suspend-Processor' |
|
880 | + | arguments = [(b'storepath', Path()), |
|
881 | + | (b'storeid', Integer())] |
|
881 | 882 | ||
882 | 883 | ||
883 | 884 | ||
884 | - | class ResumeProcessor(juice.Command): |
|
885 | + | class ResumeProcessor(Command): |
|
885 | 886 | """ |
|
886 | 887 | Cause a particular reliable listener to begin receiving notifications |
|
887 | 888 | again. |
|
888 | 889 | """ |
|
889 | - | commandName = 'Resume-Processor' |
|
890 | - | arguments = [('storepath', juice.Path()), |
|
891 | - | ('storeid', juice.Integer())] |
|
890 | + | commandName = b'Resume-Processor' |
|
891 | + | arguments = [(b'storepath', Path()), |
|
892 | + | (b'storeid', Integer())] |
|
892 | 893 | ||
893 | 894 | ||
894 | 895 | ||
895 | - | class CallItemMethod(juice.Command): |
|
896 | + | class CallItemMethod(Command): |
|
896 | 897 | """ |
|
897 | 898 | Invoke a particular method of a particular item. |
|
898 | 899 | """ |
|
899 | - | commandName = 'Call-Item-Method' |
|
900 | - | arguments = [('storepath', juice.Path()), |
|
901 | - | ('storeid', juice.Integer()), |
|
902 | - | ('method', juice.String())] |
|
900 | + | commandName = b'Call-Item-Method' |
|
901 | + | arguments = [(b'storepath', Path()), |
|
902 | + | (b'storeid', Integer()), |
|
903 | + | (b'method', String())] |
|
903 | 904 | ||
904 | 905 | ||
905 | 906 | @implementer(iaxiom.IBatchService) |
@@ -937,7 +938,8 @@
Loading
937 | 938 | ||
938 | 939 | ||
939 | 940 | def _setStore(self): |
|
940 | - | return SetStore(storepath=self.store.dbdir).do(self.batchController.juice) |
|
941 | + | return self.batchController.juice.callRemote( |
|
942 | + | SetStore, storepath=self.store.dbdir) |
|
941 | 943 | ||
942 | 944 | ||
943 | 945 | def _restartProcess(self): |
@@ -960,9 +962,11 @@
Loading
960 | 962 | item = itemMethod.im_self |
|
961 | 963 | method = itemMethod.im_func.func_name |
|
962 | 964 | return self.batchController.getProcess().addCallback( |
|
963 | - | CallItemMethod(storepath=item.store.dbdir, |
|
964 | - | storeid=item.storeID, |
|
965 | - | method=method).do) |
|
965 | + | lambda proto: proto.callRemote( |
|
966 | + | CallItemMethod, |
|
967 | + | storepath=item.store.dbdir, |
|
968 | + | storeid=item.storeID, |
|
969 | + | method=method)) |
|
966 | 970 | ||
967 | 971 | ||
968 | 972 | def start(self): |
@@ -972,12 +976,14 @@
Loading
972 | 976 | ||
973 | 977 | def suspend(self, storepath, storeID): |
|
974 | 978 | return self.batchController.getProcess().addCallback( |
|
975 | - | SuspendProcessor(storepath=storepath, storeid=storeID).do) |
|
979 | + | lambda proto: proto.callRemote( |
|
980 | + | SuspendProcessor, storepath=storepath, storeid=storeID)) |
|
976 | 981 | ||
977 | 982 | ||
978 | 983 | def resume(self, storepath, storeID): |
|
979 | 984 | return self.batchController.getProcess().addCallback( |
|
980 | - | ResumeProcessor(storepath=storepath, storeid=storeID).do) |
|
985 | + | lambda proto: proto.callRemote( |
|
986 | + | ResumeProcessor, storepath=storepath, storeid=storeID)) |
|
981 | 987 | ||
982 | 988 | ||
983 | 989 |
@@ -1036,11 +1042,10 @@
Loading
1036 | 1042 | siteStore = None |
|
1037 | 1043 | ||
1038 | 1044 | def __init__(self, service=None, issueGreeting=False): |
|
1039 | - | juice.Juice.__init__(self, issueGreeting) |
|
1045 | + | AMP.__init__(self) |
|
1040 | 1046 | self.storepaths = [] |
|
1041 | - | if service is not None: |
|
1042 | - | service.cooperator = cooperator.Cooperator() |
|
1043 | 1047 | self.service = service |
|
1048 | + | self.isServer = issueGreeting |
|
1044 | 1049 | ||
1045 | 1050 | ||
1046 | 1051 | def connectionLost(self, reason): |
@@ -1050,6 +1055,7 @@
Loading
1050 | 1055 | reactor.stop() |
|
1051 | 1056 | ||
1052 | 1057 | ||
1058 | + | @SetStore.responder |
|
1053 | 1059 | def command_SET_STORE(self, storepath): |
|
1054 | 1060 | from axiom import store |
|
1055 | 1061 |
@@ -1062,22 +1068,20 @@
Loading
1062 | 1068 | ||
1063 | 1069 | return {} |
|
1064 | 1070 | ||
1065 | - | command_SET_STORE.command = SetStore |
|
1066 | - | ||
1067 | 1071 | ||
1072 | + | @SuspendProcessor.responder |
|
1068 | 1073 | def command_SUSPEND_PROCESSOR(self, storepath, storeid): |
|
1069 | 1074 | return self.subStores[storepath.path].suspend(storeid).addCallback(lambda ign: {}) |
|
1070 | - | command_SUSPEND_PROCESSOR.command = SuspendProcessor |
|
1071 | 1075 | ||
1072 | 1076 | ||
1077 | + | @ResumeProcessor.responder |
|
1073 | 1078 | def command_RESUME_PROCESSOR(self, storepath, storeid): |
|
1074 | 1079 | return self.subStores[storepath.path].resume(storeid).addCallback(lambda ign: {}) |
|
1075 | - | command_RESUME_PROCESSOR.command = ResumeProcessor |
|
1076 | 1080 | ||
1077 | 1081 | ||
1082 | + | @CallItemMethod.responder |
|
1078 | 1083 | def command_CALL_ITEM_METHOD(self, storepath, storeid, method): |
|
1079 | 1084 | return self.subStores[storepath.path].call(storeid, method).addCallback(lambda ign: {}) |
|
1080 | - | command_CALL_ITEM_METHOD.command = CallItemMethod |
|
1081 | 1085 | ||
1082 | 1086 | ||
1083 | 1087 | def _pollSubStores(self): |
@@ -1207,7 +1211,7 @@
Loading
1207 | 1211 | ||
1208 | 1212 | def startService(self): |
|
1209 | 1213 | service.Service.startService(self) |
|
1210 | - | self.parent.cooperator.coiterate(self.processWhileRunning()) |
|
1214 | + | cooperate(self.processWhileRunning()) |
|
1211 | 1215 | ||
1212 | 1216 | ||
1213 | 1217 | def stopService(self): |
Files | Coverage |
---|---|
axiom | 93.32% |
Project Totals (98 files) | 93.32% |
gh-2.7-twlowest
gh-2.7-twpy27
gh-pypy2-twlowest
gh-pypy2-twpy27
gh-2.7-twpy27
gh-2.7-twlowest
gh-pypy2-twlowest
gh-pypy2-twpy27
gh-pypy2-twpy27
gh-pypy2-twlowest
gh-2.7-twpy27
gh-2.7-twlowest
gh-pypy2-twlowest
gh-pypy2-twpy27
gh-2.7-twlowest
gh-2.7-twpy27
gh-pypy2-twpy27
gh-pypy2-twlowest
gh-2.7-twpy27
gh-2.7-twlowest
gh-2.7-twpy27
gh-2.7-twpy27
gh-2.7-twlowest
gh-2.7-twlowest
gh-2.7-twpy27
gh-pypy2-twlowest
gh-pypy2-twpy27
gh-2.7-twlowest
gh-2.7-twpy27
gh-pypy2-twlowest
gh-pypy2-twpy27
gh-2.7-twpy27
gh-2.7-twlowest
gh-pypy2-twpy27
gh-pypy2-twlowest
gh-pypy2-twpy27
gh-pypy2-twlowest
gh-2.7-twlowest
gh-2.7-twpy27
gh-pypy2-twpy27
gh-pypy2-twlowest
gh-2.7-twlowest
gh-2.7-twpy27
gh-pypy2-twpy27
gh-pypy2-twlowest
gh-2.7-twpy27
gh-2.7-twlowest
gh-pypy2-twpy27
gh-pypy2-twlowest
gh-2.7-twpy27
gh-2.7-twlowest
gh-pypy2-twpy27
gh-pypy2-twlowest
gh-2.7-twlowest
gh-2.7-twpy27
gh-pypy2-twpy27
gh-pypy2-twlowest
gh-2.7-twlowest
gh-2.7-twpy27
gh-pypy2-twpy27
gh-pypy2-twlowest
gh-2.7-twlowest
gh-2.7-twpy27
gh-pypy2-twlowest
gh-pypy2-twpy27
gh-2.7-twpy27
gh-2.7-twlowest
gh-pypy2-twlowest
gh-pypy2-twpy27
gh-2.7-twpy27
gh-2.7-twlowest
gh-pypy2-twpy27
gh-pypy2-twlowest
gh-2.7-twlowest
gh-2.7-twpy27
gh-pypy2-twpy27
gh-pypy2-twlowest
gh-2.7-twlowest
gh-2.7-twpy27
gh-pypy2-twpy27
gh-pypy2-twlowest
gh-2.7-twlowest
gh-2.7-twpy27
gh-pypy2-twpy27
gh-pypy2-twlowest
gh-2.7-twlowest
gh-2.7-twpy27
gh-pypy2-twpy27
gh-pypy2-twlowest
gh-2.7-twpy27
gh-2.7-twlowest
gh-pypy2-twlowest
gh-pypy2-twpy27
gh-pypy2-twpy27
gh-pypy2-twlowest
gh-pypy2-twpy27
gh-pypy2-twlowest
gh-2.7-twlowest
gh-2.7-twpy27
gh-pypy2-twlowest
gh-pypy2-twpy27
gh-2.7-twlowest
gh-2.7-twpy27
gh-pypy2-twlowest
gh-pypy2-twpy27
gh-2.7-twpy27
gh-2.7-twlowest
gh-pypy2-twlowest
gh-pypy2-twpy27
gh-2.7-twpy27
gh-2.7-twlowest
gh-pypy2-twlowest
gh-pypy2-twpy27
gh-2.7-twpy27
gh-2.7-twlowest
gh-pypy2-twlowest
gh-2.7-twpy27
gh-2.7-twlowest
gh-2.7-twpy27
gh-pypy2-twlowest
gh-pypy2-twlowest
gh-2.7-twlowest
gh-2.7-twpy27
gh-pypy2-twpy27
gh-pypy2-twlowest
gh-2.7-twlowest
gh-pypy2-twpy27
gh-2.7-twlowest
gh-2.7-twlowest
gh-2.7-twpy27
gh-pypy2-twpy27
gh-pypy2-twlowest
gh-2.7-twlowest
gh-2.7-twpy27
gh-pypy2-twpy27
gh-pypy2-twlowest
gh-2.7-twpy27
gh-2.7-twlowest
gh-2.7-twpy27
gh-2.7-twlowest
gh-2.7-twlowest
gh-2.7-twpy27
gh-pypy2-twpy27
gh-pypy2-twlowest
gh-2.7-twlowest
gh-2.7-twpy27
gh-pypy2-twpy27
gh-pypy2-twlowest
gh-pypy2-twpy27
gh-pypy2-twlowest
gh-pypy2-twpy27
Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file.
The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files.
The size and color of each slice is representing the number of statements and the coverage, respectively.