instance

how to kill twisted protocol instances python

a 夏天 提交于 2019-12-10 21:24:27
问题 I have a server application written in python using twisted and I'd like to know how to kill instances of my protocol (bottalk). Everytime I get a new client connection, I see the instance in memory (print Factory.clients) .. but let's say I want to kill one of those instances from the server side (drop a specific client connection)? Is this possible? I've tried looking for a phrase using lineReceived, then if it matches, self.transport.loseConnection(). But that doesn't seem to reference the

How to get a module instance in PRISM

只愿长相守 提交于 2019-12-10 21:17:11
问题 I have a PRISM desktop app which loads modules from a directory with the help of the DirectoryModuleCatalog. Everything is fine, except that I cannot find a way to get the instance of a loaded module. IModuleManager and IModuleCatalog don't have a method like getInstance(ModuleInfo) or similar. See moduleManager.LoadModule(moduleInfo.ModuleName); This line loads the module properly(moduleManager is of type IModuleManager), but what do I have to do next to get the actual instance of this

How to get an instance variable from rails using angularjs and ui router?

℡╲_俬逩灬. 提交于 2019-12-10 20:43:06
问题 I'm using a template in my state router. I want to get an instance variable from my rails server, but it doesn't have it's own path, so I can't use Restangular or something like that. Also, when I try to interpolate: #{@variable} nothing happens, because I'm in a template in my ui router, and not in a rails view. So how do I get an instance variable from my rails server into angularjs in a ui-router template? EDIT: ahaa.... just pass it in like this: ng-init="variablename = 'variable'" so in

Getting object name in Objective-c

为君一笑 提交于 2019-12-10 19:29:12
问题 suppose i have a class Foo and an instance of this class myFoo: Foo *myFoo; is there any method "dispalyFooObjectName" that can display the name of the object, for exmample : NSLog(@"i was called from %s", [myFoo dispalyFooObjectName]); and the result will be : i was called from myFoo 回答1: In most programming languages objects don't have names. Just because some variable myFoo references your object, doesn't mean that your object is "called" myFoo . And in most C-based languages variable

Memory usage of class instance in c# [duplicate]

筅森魡賤 提交于 2019-12-10 18:43:37
问题 This question already has answers here : Closed 8 years ago . Possible Duplicate: How much memory does a C#/.NET object use? Like the title says, how can I check how much memory a class instance takes in memory in c# (webforms) 回答1: private System.Diagnostics.PerformanceCounter ramCounter; ramCounter = new System.Diagnostics.PerformanceCounter("Memory", "Available MBytes"); public string getAvailableRAM() { return ramCounter.NextValue() + "Mb"; } Those be the tools to your disposal :D

Is it possible to change dynamically the name of the class in the code with a variable?

杀马特。学长 韩版系。学妹 提交于 2019-12-10 18:12:55
问题 I have this function : - (NSString*) getId:(id)id_field withColumn:(int)test_column withTable:(NSString *) tableName //renvoyer le label { NSError *error = nil; NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init]; NSEntityDescription *entity = [NSEntityDescription entityForName:tableName inManagedObjectContext:managedObjectContext]; [fetchRequest setEntity:entity]; NSArray *fetchedObjects = [managedObjectContext executeFetchRequest:fetchRequest error:&error]; for (<tableName of class

Difference between accessing an instance attribute and a class attribute

房东的猫 提交于 2019-12-10 18:10:38
问题 I have a Python class class pytest: i = 34 def func(self): return "hello world" When I access pytest.i , I get 34. I can also do this another way: a = pytest() a.i This gives 34 as well. If I try to access the (non-existing) pytest.j , I get Traceback (most recent call last): File "<pyshell#6>", line 1, in <module> pytest.j AttributeError: class pytest has no attribute 'j' while when I try a.j , the error is Traceback (most recent call last): File "<pyshell#8>", line 1, in <module> a.j

How to share an instance of a class with many classes?

大兔子大兔子 提交于 2019-12-10 17:16:39
问题 I have a c# web service. When I get a new request I create a logging instance. I have many other instances of other classes to process the request and I want them to log as well. What is the best way to share logging instance without passing it in constructors or properties ? 回答1: Singleton Pattern is an anti-pattern; I can not think of many instances where it should be used or recommended, including in this instance, for logging. How we handle logging: A logging instance is injected into all

An error occurred creating the form. See Exception.InnerException for details. The error is: Object reference not set to an instance of an object

佐手、 提交于 2019-12-10 15:14:33
问题 I get this error when attempting to debug my form, I cannot see where at all the error could be (also does not highlight where), anyone have any suggestions? An error occurred creating the form. See Exception.InnerException for details. The error is: Object reference not set to an instance of an object. Dim dateCrap As String = "Date:" Dim IPcrap As String = "Ip:" Dim pcCrap As String = "Computer:" Dim programCrap As String = "Program:" Dim textz As String Dim sep() As String = {vbNewLine &

Error: “x instance has no attribute y” when trying to inherit from class

偶尔善良 提交于 2019-12-10 14:16:30
问题 I can't really understand what I'm doing wrong, since when I try it in "small scale" and it is working there. I have a class named Play() I goes like this: class Play(): def __init__(self): file = open("/home/trufa/Desktop/test", "r") self.word = random.choice(file.readlines()).rstrip() self.errAllowed = 7 self.errMade = 0 self.errList = [] self.cheatsAllowed = 2##chetas not incrementing self.cheatsMade =0 self.wordList = ["*"]*len(self.word) ##this one is the one I want to have available in