463
464
465# Basic clients and associated factories.
466class CarbonPickleClientProtocol(CarbonClientProtocol, Int32StringReceiver):467
468 def _sendDatapointsNow(self, datapoints):
469 self.sendString(pickle.dumps(datapoints, protocol=2))
476 return CarbonPickleClientProtocol()
477
478
479class CarbonLineClientProtocol(CarbonClientProtocol, LineOnlyReceiver):480
481 def _sendDatapointsNow(self, datapoints):
482 for metric, datapoint in datapoints:
6
7class ProcessorTest(TestCase):
8 def test_processor_registers(self):
9 class DummyProcessor(Processor):10 plugin_name = "dummy_processor"
11
12 self.assertTrue("dummy_processor" in Processor.plugins)
28 return pickle_loads(data[INT32_SIZE:INT32_SIZE + pickle_size])
29
30
31class BroadcastRouter(DatapointRouter): 32 def __init__(self, destinations=[]):
33 self.destinations = set(destinations)
34
28 return pickle_loads(data[INT32_SIZE:INT32_SIZE + pickle_size])
29
30
31class BroadcastRouter(DatapointRouter): 32 def __init__(self, destinations=[]):
33 self.destinations = set(destinations)
34
A method marked with @abstractmethod
is not defined in the concrete class. This can result in unintended behavior.
It is recommended to implement all abstract methods in the derived classes.
from abc import ABC, abstractmethod
class Vehicle(ABC):
@abstractmethod
def start():
pass
class Car(Vehicle):
# No overridden `start` method here. Can cause unintended behavior
def stop():
self.speed = 0
from abc import ABC, abstractmethod
class Vehicle(ABC):
@abstractmethod
def start():
pass
class Car(Vehicle):
def start():
self.speed = 3
def stop():
self.speed = 0