What is difference between waitForAngularEnabled and browser.ignoreSynchronization in protractor? - protractor

What is browser.ignoreSynchronization?
/**
* If true, Protractor will not attempt to synchronize with the page before
* performing actions. This can be harmful because Protractor will not wait
* until $timeouts and $http calls have been processed, which can cause
* tests to become flaky. This should be used only when necessary, such as
* when a page continuously polls an API using $timeout.
*
* #type {boolean}
*/
&
waitForAngularEnabled
Both looks same. Is there any specific thing that can achieve by one and not by other?

They are the exact same, if you look at the source code ignoreSynchronization actually calls waitForAngularEnabled. The only thing to note is, ignoreSynchronization is being deprecated and eventually will no longer be available. They are switching to waitForAngularEnabled as the main property.
As far as what they do, that has been answered here in good detail.

Related

(Laravel 5) Monitor and optionally cancel an ALREADY RUNNING job on queue

I need to achieve the ability to monitor and be able to cancel an ALREADY RUNNING job on queue.
There's a lot of answers about deleting QUEUED jobs, but not on an already running one.
This is the situation: I have a "job", which consists of HUNDREDS OF THOUSANDS rows on a database, that need to be queried ONE BY ONE against a web service.
Every row needs to be picked up, queried against a web service, stored the response and its status updated.
I had that already working as a Command (launching from / outputting to console), but now I need to implement queues in order to allow piling up more jobs from more users.
So far I've seen Horizon (which doesn't runs on Windows due to missing process control libs). However, in some demos seen around it lacks (I believe) a couple things I need:
Dynamically configurable timeout (the whole job may take more than 12 hours, depending on the number of rows to process on the selected job)
Ability to CANCEL an ALREADY RUNNING job.
I also considered the option to generate EACH REQUEST as a new job instead of seeing a "job" as the whole collection of rows (this would overcome the timeout thing), but that would give me a Horizon "pending jobs" list of hundreds of thousands of records per job, and that would kill the browser (I know Redis can handle this without itching at all). Further, I guess is not possible to cancel "all jobs belonging to X tag".
I've been thinking about hitting an API route, fire the job and decouple it from the app, but I'm seeing that this requires forking processes.
For the ability to cancel, I would implement a database with job_id, and when the user hits an API to cancel a job, I'd mark it as "halted". On every loop I would check its status and if it finds "halted" then kill itself.
If I've missed any aspect just holler and I'll add it or clarify about it.
So I'm asking for an advice here since I'm new to Laravel: how could I achieve this?
So I finally came up with this (a bit clunky) solution:
In Controller:
public function cancelJob()
{
$jobs = DB::table('jobs')->get();
# I could use a specific ID and user owner filter, etc.
foreach ($jobs as $job) {
DB::table('jobs')->delete($job->id);
}
# This is a file that... well, it's self explaining
touch(base_path(config('files.halt_process_signal')));
return "Job cancelled - It will stop soon";
}
In job class (inside model::chunk() function)
# CHECK FOR HALT SIGNAL AND [OPTIONALLY] STOP THE PROCESS
if ($this->service->shouldHaltProcess()) {
# build stats, do some cleanup, log, etc...
$this->halted = true;
$this->service->stopProcess();
# This FALSE is what it makes the chunk() method to stop looping
return false;
}
In service class:
/**
* Checks the existence of the 'Halt Process Signal' file
*
* #return bool
*/
public function shouldHaltProcess() :bool
{
return file_exists($this->config['files.halt_process_signal']);
}
/**
* Stop the batch process
*
* #return void
*/
public function stopProcess() :void
{
logger()->info("=== HALT PROCESS SIGNAL FOUND - STOPPING THE PROCESS ===");
$this->deleteHaltProcessSignalFile();
return ;
}
It doesn't looks quite elegant, but it works.
I've surfed the whole web and many goes for Horizon or other tools that doesn't fit my case.
If anyone has a better way to achieve this, it's welcome to share.
Laravel queue have 3 important config:
1. retry_after
2. timeout
3. tries
See more: https://laravel.com/docs/5.8/queues
Dynamically configurable timeout (the whole job may take more than 12
hours, depending on the number of rows to process on the selected job)
I think you can config timeout + retry_after about 24h.
Ability to CANCEL an ALREADY RUNNING job.
Delete job in jobs table
Delete process by process id in your server
Hope it help you :)

Flutter on VS Code issue: StreamController.Sink.add() suddenly require argument PUSH

Good afternoon good people,
I'm suddenly experiencing a problem with VS Code:
in a couple of Flutter apps Streamcontroller.sink.add();
suddenly require the argument "push" (before it didn't).
without adding the push argument obviously it return the error
2 required argument(s) expected, but 1 found.dart(not_enough_required_arguments)
Does anyone know what might have happened?
thank you in advance for your help
Francesco
edit: via f12 the definition actually shows the argument push
part of dart.core;
/**
* A generic destination for data.
*
* Multiple data values can be put into a sink, and when no more data is
* available, the sink should be closed.
*
* This is a generic interface that other data receivers can implement.
*/
abstract class Sink<T> {
/**
* Adds [data] to the sink.
*
* Must not be called after a call to [close].
*/
void add(T data, Future push);
/**
* Closes the sink.
*
* The [add] method must not be called after this method.
*
* Calling this method more than once is allowed, but does nothing.
*/
void close();
}
but as pskink reminded the documentation doesn't show this requirement;
I don't have idea how this can have changed,
at this point the question is:
how do I restore it to normality?
TL;DR
what appeared to be bad code,
was instead corrupted dart code;
I followed the instruction provide by Gunter
and everything went back to normal.
Thanks again Gunter

Is it safe to use performance.now() to measure page load time in GWT?

I need to measure the time required for my GWT application to load.
I can't use GWT Lightweight Metrics because of external framework usage (I can't modify bootstrap html page).
Navigation Timing doesn't work for GWT because initialization of GWT widgets doesn't depend on window.load.
So, is it safe to use performance.now() method to get the time from PerformanceTiming.navigationStart event?
Specs says that:
The now() method must return a DOMHighResTimeStamp representing the time in milliseconds from the time origin to the occurrence of the call to the Performance.now method.
I can't understand time origin definition. Does it always return the time from the moment when the user requests a page with my application?
I haven't found answer to my original question. It seems like performance.now() isn't suitable for measuring page loading time.
I have used explicit approach described here.
The code is something like this.
public static long getTimeFromPageLoadStart() {
long navigationStart = (long) getNavigationStart();
return new Date().getTime() - navigationStart;
}
private static native double getNavigationStart()/*-{
return performance.timing.navigationStart;
}-*/;

How to ignore some subroutine calls in NYTProf reporting

I'm trying to profile a Perl script, but CORE::sleep gobble all the space (and time) of my report.
How can i tell NYTProf to ignore sleep calls ?
Assuming we have the following script :
sub BrandNewSubroutine {
sleep 10;
print "Odelay\n";
}
BrandNewSubroutine();
I want to get rid of the following line of the report :
Exclusive Time;Inclusive Time;Subroutine
10.0s;10.0s;main::::CORE:sleepmain::CORE:sleep
(opcode)
Edit: Using DB::disable_profile() and DB::enable_profile() won't do the trick, as it add sleep time to BrandNewSubroutine Inclusive time.
Thanks in advance.
I'd suggest either wrapping the calls to sleep (possibly by use of method mentioned in perlsub) with DB::disable_profile() and DB::enable_profile() calls (RUN-TIME CONTROL OF PROFILING in NYTProf documentation), or post processing the report to remove the offending calls.
CORE::accept is already ignored in the way you'd like CORE::sleep to be, so the mechanism is already in place. See this code in NYTProf.xs:
/* XXX make configurable eg for wait(), and maybe even subs like FCGI::Accept
* so perhaps use $hide_sub_calls->{$package}{$subname} to make it general.
* Then the logic would have to move out of this block.
*/
if (OP_ACCEPT == op_type)
subr_entry->hide_subr_call_time = 1;
So with a little hacking (OP_SLEEP==op_type || OP_ACCEPT == op_type) you'd be able to ignore CORE::sleep in the same way.
I'd accept a patch to enable that as an option.

TTURLCache to cache my image and data

I used three20's photo gallery in my app and it worked really well and looked neat and pretty. And basically I don't need to worry about all the fetch-photos-from-the-server thing since three20 has fetched and managed and cached the data for me, all of which are done behind the scene.
That's when I started to notice this magic caching mechanism implemented in three20, called TTURLCache. In its header file I find the following interface methods:
/**
* Stores a data on disk.
*/
- (void)storeData:(NSData*)data forURL:(NSString*)URL; //method 1
- (void)storeData:(NSData*)data forKey:(NSString*)key;
/**
* Stores an image in the memory cache.
*/
- (void)storeImage:(UIImage*)image forURL:(NSString*)URL; //method 2
/**
* Stores an etag value in the etag cache.
*/
- (void)storeEtag:(NSString*)etag forKey:(NSString*)key; //method 3
My questions:
Method 1 and method 2 in the above code: are they only capable of storing data, or are they capable of both fetching and storing?
What is an etag in method 3?
Method 1 says it will store the data on disk, while method 2 says it will store the image in memory. If I use method 2 to store an image, will it get lost once I kill and restart my app?
Thanks a lot in advance.
Those are the storage methods. The retrieval methods are separate. (See below.)
Etags are a way to optimize network traffic. See Wikipedia for a good intro.
I think that Three20 both stores the image file on disk, and the decoded image itself in memory. Certainly, any in-memory caches would be cleared if the app re-started, but remember that under iOS 4, that probably happens less often that you think.
To get data out of the cache, try one of:
/**
* Gets the data for a URL from the cache if it exists and is newer than a minimum timestamp.
*
* #return nil if hthe URL is not cached or if the cache entry is older than the minimum.
*/
- (NSData*)dataForURL:(NSString*)URL expires:(NSTimeInterval)expirationAge
timestamp:(NSDate**)timestamp;
- (NSData*)dataForKey:(NSString*)key expires:(NSTimeInterval)expirationAge
timestamp:(NSDate**)timestamp;
/**
* Gets an image from the in-memory image cache.
*
* #return nil if the URL is not cached.
*/
- (id)imageForURL:(NSString*)URL;
- (id)imageForURL:(NSString*)URL fromDisk:(BOOL)fromDisk;
I would advise reading through the source, though. If memory serves, TTURLCache isn't all that big a class.