Questions tagged [callable]

A task that returns a result and may throw an exception.

The Callable interface is similar to Runnable, in that both are designed for classes whose instances are potentially executed by another thread. A Runnable, however, does not return a result and cannot throw a checked exception.

759 questions
3
votes
1 answer

iter(callable, sentinel) form on byte array

I am using an API that returns messages terminated by a \x04 (end of transmission) byte. I would like to catch this byte in a nice way. This is the code I wrote: # Only works if buffer size is 1 byte read = lambda: self._sslsocket.recv(1) response…
xy2_
  • 31
  • 3
3
votes
1 answer

Reactive Programming in Java deep understanding

In order to have a deep understanding of Reactive Programming I was trying to reimplement, in a very simple way, the RxJava Observable class. This made me ask some important questions about reactive programming approach. I want to share them with…
3
votes
2 answers

Python: Pass extra arguments to callable

I have the following python code: import networkx as nx def cost(i, j, d, value1, value2): # some operation involving all these values return cost # graph is a networkx graph # src, dst are integers # cost is a callable that is passed 3…
Niloy Saha
  • 444
  • 2
  • 4
  • 14
3
votes
2 answers

Does not calling Future.get cause any issue?

I am executing a certain flow wherein I submit some task to Callable and store the output in Future<> future. In some of the cases I am not calling future.get() to retrieve the value nor am I cancelling the task. Can this cause any issue?
Faiz Kidwai
  • 463
  • 5
  • 26
3
votes
0 answers

How to design AsyncTask using Java Callable and Future?

I am working on Java implementation of an Android class AsyncTask I am using the Future and Callable classes of Java . Here is my Async Task :- public abstract class AsyncTask{ ExecutorService executor =…
3
votes
3 answers

How much logic is it "right" to put in a Callable?

I'm using callables quite often , and I've stubled upon a question that irritates me: Lets say that to run function foo() , one needs to do a couple of checks first. Should you 1. Insert the checks as part of the Callable : class A implements…
Yossale
  • 14,165
  • 22
  • 82
  • 109
3
votes
1 answer

Python: Convert str format to callable method

I do not quite know what to google to find a solution for my problem so I will try to find it here. I am creating a Gui in Python 3.5.2 with pygame. I am currenctly working on Error popups that have a different button function depending on the error…
Julian
  • 135
  • 2
  • 8
3
votes
2 answers

Read large file multithreaded

I am implementing a class that should receive a large text file. I want to split it in chunks and each chunk to be hold by a different thread that will count the frequency of each character in this chunk. I expect with starting more threads to get…
barni
  • 49
  • 1
  • 2
  • 7
3
votes
1 answer

what is the difference between Callable statement and Prepared Statement in Sql?

Can anyone please explain the difference between Callable and Prepared Statement in Sql with any example?
Nolimits
  • 43
  • 1
  • 3
3
votes
2 answers

Limit concurrent method executions inside call()

I have a call() method in my code, which based on certain conditions calls specific methods : call(){ if(a){ methodA(); } if(b){ methodB(); } if(c){ methodC(); } } In the above scenario, I want to limit concurrent…
Ami
  • 33
  • 3
3
votes
1 answer

Can't get rid of TypeError: 'str' object is not callable

I'm trying to make/train a twitter sentiment analyser in ipython notebook and am having serious problems with one section of code: import csv #Read the tweets one by one and process it inpTweets = csv.reader(open('SampleTweets.csv', 'rb'),…
3
votes
1 answer

Is it possible to pass Function to ExecutorService instead of callable in Java 8?

public class myService { @Autowired ExecutorService executor; public Result getServiceResult(Token token, Profile profile){ //validate token and profile return getResult(token, profile).get(); } private…
brain storm
  • 30,124
  • 69
  • 225
  • 393
3
votes
3 answers

Callable Threads versus Runnable Threads versus Extend Thread

I was recently reading about creation of Threads in java by implementing Runnable or Extending thread and last Implementing Callable. Runnable Versus Callable thread at stackoverflow describes the difference quoting both are designed for classes…
Vivek Vardhan
  • 1,118
  • 3
  • 21
  • 44
3
votes
1 answer

How to get the class from a callable

In this situation: $callable1 = "\somenamespace\someclass::somefunction"; $callable2 = array('someclass', 'somefunction'); $callable3 = 'somefunction'; $callable4 = array($someInstance, 'somefunction'); Is there a way I can reliably extract the…
KrekkieD
  • 967
  • 9
  • 23
3
votes
1 answer

Filling SWT table object using a separated thread class

I've got a code snippet by the swt team that does exactly what I need. However, there is a part I want to separate into another class, in particular, the whole inline stuff. In response to my former question, it has been suggested that Callable…
Ta Sas
  • 9,573
  • 15
  • 51
  • 73