[Gambas-user] gambas | Draft: DBus, add ConnectionExists boolean property (!238)

bb adamnt42 at gmail.com
Thu Jul 8 20:08:37 CEST 2021


On Thu, 2021-07-08 at 17:51 +0000, Bruce Steers (@bsteers4) wrote:
> Bruce Steers created a merge request: !238
> 
> Project:Branches: bsteers4/gambas:dbus-connectionexists to
> gambas/gambas:master
> Author: Bruce Steers
> Assignees:
> Reviewers:
> [GB.DBUS]
> 
> NEW: ConnectionExists boolean property sets true if connection fails
> due to already existing connection.
> It's a solution. Or maybe just a workaround? With this if Register()
> fails and ConnectionExists = False i know i have a different error.
> 
> I understand if you think it's not the best idea and you have a
> better idea :)
> 

Bruce,

It's not the connection that is failing. It is the attempted
registration.

>From memory, checking whether a (any) dbus server already exists can be
done by simply trying to connect to it. BUT! as Benoit said, that is
not a "atomic" process.
The way he described is the best way to do such a "set and test" check.

	try(set registration)
	except (set error)

	on_error(do something)
	else (do something else, like attempt to "become" the server*)

So it's actually failing successfully (!)

b

* a BAD idea imo. Servers should serve, clients should be simple and
stupid.
! You also have the problem when using an asynchronous check in that
the server may well exit between the check and the subsequent attempt
to use that server.




More information about the User mailing list